Skip to content

docs(forecasting): surface DeliveryForecast / forecast_range_unit across seller skill - #1398

Merged
bokelley merged 3 commits into
mainfrom
bokelley/forecast-docs-1379
May 3, 2026
Merged

bokelley merged 3 commits into
mainfrom
bokelley/forecast-docs-1379

Conversation

@bokelley

@bokelley bokelley commented May 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #1379.

Adopters were missing AdCP 3.0.4's reverse-forecast surface because nothing in the skill prose pointed at Product.forecast / forecast_range_unit. The schema already supports forward ('spend'), reverse ('conversions' / 'clicks'), availability, package, weekly, daily, and reach/freq curves — including the Meta-style "tell me your goal, I'll tell you the budget" planning question called out verbatim in the schema description.

This PR surfaces that capability so seller adapters actually populate it.

Changes

  • New docs/guides/FORECASTING.md — canonical reference with worked examples for each forecast_range_unit value, schema citations, and a per-specialism unit-selection table.
  • skills/build-seller-agent/SKILL.md — new ### 4. Forecast & planning surface between Pricing and Approval Workflow, with a per-specialism canonical-units table that links to the guide. Renumbered subsequent section (Creative Management 5 → 6).
  • Per-specialism deltas point at the guide:
    • sales-non-guaranteed.md — 'spend' forward curves
    • sales-guaranteed.md — 'availability' (single point, no budget)
    • sales-social.md — 'conversions' / 'clicks' reverse curves
    • sales-broadcast-tv.md — 'reach_freq' and 'package'

Docs-only — no library/CLI changes, no changeset needed.

Test plan

  • npx prettier --check passes
  • Pre-push typecheck passes
  • CI: lint + format gates
  • Spot-read FORECASTING.md sections render correctly
  • Confirm anchor links from each specialism file resolve to the right section

🤖 Generated with Claude Code

bokelley and others added 3 commits May 2, 2026 21:31
…oss seller skill — closes #1379

Adopters were missing AdCP 3.0.4's reverse-forecast surface because nothing in
the skill prose pointed at `Product.forecast` / `forecast_range_unit`. The
schema already supports forward (`'spend'`), reverse (`'conversions'` /
`'clicks'`), availability, package, weekly, daily, and reach/freq curves —
including the Meta-style "tell me your goal, I'll tell you the budget"
planning question called out verbatim in the schema description.

- New `docs/guides/FORECASTING.md` — canonical reference with worked examples
  for each `forecast_range_unit` value, schema citations, and a per-specialism
  unit-selection table.
- `skills/build-seller-agent/SKILL.md` — new "### 4. Forecast & planning
  surface" between Pricing and Approval Workflow, with a per-specialism
  canonical-units table that links to the guide.
- Per-specialism deltas point at the guide:
  - `sales-non-guaranteed.md` — `'spend'` forward curves
  - `sales-guaranteed.md` — `'availability'` (single point, no budget)
  - `sales-social.md` — `'conversions'` / `'clicks'` reverse curves
  - `sales-broadcast-tv.md` — `'reach_freq'` and `'package'`

Docs-only — no library/CLI changes, no changeset needed.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Docs-only PR but CI's changeset gate requires one for any package change.
Tagged patch since there's no library behavior change.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The AdCP spec already covers DeliveryForecast / forecast_range_unit
comprehensively at docs/media-buy/product-discovery/media-products.mdx
(budget curves, availability, CTV/GRP, retail-media outcomes).
Duplicating it in the SDK invites drift.

- Delete docs/guides/FORECASTING.md.
- SKILL.md § 4 now points at the spec page; keeps the SDK-specific
  per-specialism canonical-units table since that's adopter guidance,
  not protocol surface.
- Each specialism delta links to the most relevant section heading
  on the spec page (Budget Curve, Availability Forecast, CTV with GRP
  Demographics, Forecast Range Units).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bokelley
bokelley merged commit 8a970ae into main May 3, 2026
10 checks passed
bokelley added a commit that referenced this pull request May 3, 2026
…anteed/social (#1375 #1378)

Pre-rebase snapshot of work from this session. Mock endpoints, tests, skill docs,
typecheck-skill-examples harness extension. Will rebase onto current origin/main
(which has #1373 worked adapters and #1398 docs) and reconcile additively.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley added a commit that referenced this pull request May 3, 2026
…ascade-scenario coverage (#1414)

* feat(mock-server, skills): forecast + planning surface for sales-guaranteed/social (#1375 #1378)

Pre-rebase snapshot of work from this session. Mock endpoints, tests, skill docs,
typecheck-skill-examples harness extension. Will rebase onto current origin/main
(which has #1373 worked adapters and #1398 docs) and reconcile additively.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat: wire forecast/availability + delivery_estimate into hello adapters; round-2 polish

Wires the new mock endpoints from the prior commit into the existing worked
adapters from #1373 so the planning surface is exercised by passing code:

- hello_seller_adapter_guaranteed.ts: getProducts now forwards req.filters
  (start_date/end_date/budget_range) to GET /v1/products and projects the
  inline upstream forecast onto Product.forecast. Adds a discrete getForecast
  upstream method for backends that don't fold forecast into the catalog
  response. UpstreamForecast / UpstreamForecastPoint / UpstreamForecastRange
  types added.

- hello_seller_adapter_social.ts: syncAudiences now calls
  POST /v1.3/advertiser/{id}/audience_reach_estimate after upload and
  populates SyncAudiencesRow.matched_count / effective_match_rate
  (real AdCP wire fields per /schemas/3.0.5/core/audience.json).

Round-2 review polish folded in:

- parseDateParam tightened from Date.parse() to ^\d{4}-\d{2}-\d{2}$ regex
  so ?flight_start=2026 doesn't hash to a different seed than 2026-01-01.
- goalCpm: reach $5→$7, video_views $8→$10 (Meta in-stream/Reels run $11-16).
- countryPopulation: IN 800M→625M, BR 175M→140M, JP 95M→85M (adult-internet
  population estimates, not total).
- Lookalike comment updated to match the cap × 0.69 effective ceiling.

All hello-adapter test gates pass (3/3 guaranteed + 3/3 social), 7747/7747
project tests pass, skill-snippet typecheck clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(hello_seller_adapter_guaranteed): wire comply_test_controller + cascade fixes

Cascade scenarios under media_buy_seller/* (driven by `requires_scenarios`
in the sales_guaranteed storyboard) previously failed and were masked by
the gate's `filterFailures`. Wires the controller and fixes the bugs that
gate was hiding, narrowing the filter to three remaining failures that are
genuine SDK-side gaps (filed for follow-up, see .context/sdk-issue-{1,2,3}*.md).

Adapter changes:
- Wire `complyTest:` config on createAdcpServerFromPlatform with seed.media_buy
  + force.media_buy_status + simulate.delivery handlers. Sandbox-gated on
  ADCP_SANDBOX === '1' so production deployments stay closed.
- Sandbox-arm in accounts.resolve: cascade scenarios send synthetic
  `account: {brand: {domain: 'test.example'}, sandbox: true}` refs that don't
  match the mock's seeded networks; resolve them to the first known network
  for sandbox-mode synthetic accounts.
- Bypass HITL handoff for sandbox accounts in createMediaBuy. Cascade
  scenarios test wire shape with synchronous create+confirm, not the
  IO-signing async flow the base storyboard tests. Same flow runs both
  paths via a shared `completeIoAndCreateLineItems` closure.
- Add `max_variance_percent < 5%` rejection to TERMS_REJECTED logic
  (was missing — measurement_terms_rejected/aggressive_terms cascade
  step expected the rejection).
- Fix `getMediaBuys` and `updateMediaBuy` `Cannot read properties of
  undefined (reading 'map')` — mock's GET /v1/orders strips line_items
  from the response (real GAM mirrors this Order vs LineItem split);
  fetch via the new `upstream.listLineItems` method.

SDK-side gaps tracked for follow-up:
- sdk-issue-1: opinionated `mediaBuyStore` for property_list/collection_list
  echo. Skill mandates `Persist the full targeting_overlay verbatim; echo
  verbatim` but every adapter has to re-implement.
- sdk-issue-2: export `MEDIA_BUY_TRANSITIONS` + `assertMediaBuyTransition`.
  Canonical state graph already exists at
  src/lib/testing/storyboard/default-invariants.ts:539 (used by the
  conformance runner) but isn't surfaced for runtime use; three example
  files copy-paste the same graph.
- sdk-issue-3: storyboard runner can't capture context_outputs.path from
  HITL task completion artifact. Runner reads taskResult.data only; HITL
  flows return submitted-task envelope with media_buy_id only landing on
  the eventual artifact. Code comment at runner.ts:2956 confirms: "the
  SDK doesn't poll synchronously after a Task with terminal state".

Tests:
- node --test test/examples/hello-seller-adapter-guaranteed.test.js — 3/3 ✓
- All 119 hello-adapter + mock-server tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(hello_seller_adapter_guaranteed): tighten sandbox gate + tag test-only paths + defend the failure allowlist

Round-3 expert review feedback. Three blockers and three converged nits:

Blockers (DX + code-review converged):
- Drop NODE_ENV==='test' from sandboxGate. Single-source on ADCP_SANDBOX=1.
  Staging environments commonly run NODE_ENV=test and the controller would
  open there too — real footgun for forks. Test gate already sets
  ADCP_SANDBOX=1 in extraEnv, so the dual-condition wasn't needed.
- Tag every test-only block with `// ─── TEST-ONLY ───` markers + add
  FORK CHECKLIST item 8 listing them explicitly. Sandbox-arm in
  accounts.resolve, HITL bypass in createMediaBuy, complyTest config,
  and in-memory seededMediaBuys/simulatedDelivery Maps. An adopter
  forking the file now gets four obvious DELETE points instead of
  silently shipping test scaffolding into prod.
- Belt-and-suspenders at the createMediaBuy bypass site: re-check
  `process.env.ADCP_SANDBOX === '1'` rather than only trusting the
  `sandbox_` id prefix flowing in from accounts.resolve. Defends
  against an upstream-resolved account somehow carrying the prefix
  without the env actually being sandbox-mode.
- Filter-allowlist defense: assert each EXPECTED_FAILURES entry appears
  in the pre-filter failure set. A spec rename or runner fix that
  silently eliminates one of the SDK-gap failures now flips the gate
  red instead of staying green on a stale allowlist.

Converged nits:
- `SANDBOX_ID_PREFIX = 'sandbox_'` constant (protocol + code-review)
- `MIN_VARIANCE_TOLERANCE = 5` lifted to module scope (code-review;
  one-place tunability for adopters)
- `// SWAP:` marker on the N+1 listLineItems pattern in getMediaBuys
  (code-review)
- Doc note on listLineItems clarifying the null→[] coercion
  (code-review)
- Per-tenant scoping SWAP marker on the in-memory Maps

EXPECTED_FAILURES now keys to GitHub issue numbers (#1415, #1416, #1417)
instead of in-repo .context/sdk-issue-*.md paths so adopters who fork
the gate test get working links.

Tests: 119/119 hello-adapter + mock-server pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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.

docs: surface AdCP DeliveryForecast / forecast_range_unit across skills + a forecasting guide

1 participant