Skip to content

feat(mock-server): sales-guaranteed forecast endpoints + hello_seller_adapter_guaranteed example - #1391

Closed
bokelley wants to merge 3 commits into
mainfrom
claude/issue-1375-guaranteed-forecast
Closed

bokelley wants to merge 3 commits into
mainfrom
claude/issue-1375-guaranteed-forecast

Conversation

@bokelley

@bokelley bokelley commented May 3, 2026

Copy link
Copy Markdown
Contributor

Closes #1375

Summary

The sales-guaranteed mock server's Product.forecast field was never exercised — MockProduct.availability was a static seed value and no adapter example existed for guaranteed sellers. This PR adds the forecast layer and a worked example.

src/lib/mock-server/sales-guaranteed/server.ts

  • Adds POST /v1/forecast — accepts { product_id, flight_dates, budget? }. When budget is absent returns an availability forecast (forecast_range_unit: 'availability'); when present returns a spend curve (forecast_range_unit: 'spend'). All response fields are deterministic given the same inputs via createHash + seedToTimestamp.
  • Extends GET /v1/products to accept ?start_date=&end_date= — when both are present, each product carries an inline DeliveryForecast (availability shape), eliminating N per-product round-trips in the adapter.

src/lib/mock-server/sales-guaranteed/openapi.yaml

  • Documents POST /v1/forecast, the new ForecastRange/ForecastPoint/DeliveryForecast schemas, and the new query params on GET /v1/products.

examples/hello_seller_adapter_guaranteed.ts (new file)

  • Worked GAM-style guaranteed seller adapter following the same pattern as hello_seller_adapter_signal_marketplace.ts.
  • getProducts calls GET /v1/products?start_date=&end_date= (single upstream call) and maps the inline forecast field onto AdCP Product.forecast.
  • createMediaBuy uses ctx.handoffToTask for IO approval polling.
  • syncCreatives, getMediaBuyDelivery fully implemented.

.changeset/mock-server-guaranteed-forecast.md — minor bump.

What was tested

  • npx tsc --noEmit — clean (pre-existing moduleResolution deprecation warning only, present on main)
  • node --test test/handler-return-tightness.test.js — pass
  • All other test failures are pre-existing (dist/ not built in this environment)

Pre-PR review

  • code-reviewer: approved after 2 iterations — all blockers resolved: DeliveryForecast.method required field populated, ForecastPoint.budget absent on availability points, DeliveryForecast.currency populated, generated_at made deterministic via seedToTimestamp, invalid ReturnType generic annotation removed
  • dx-expert: approved after 2 iterations — all blockers resolved: total_budget handles AdCP 3.x { amount, currency } shape, misleading "field names match" comment replaced with explicit field-by-field mapping, valid_until SWAP hint added, /_debug/traffic curl line added to demo, FIXME(adopter) on production-silent stubs

Nits noted but not fixed (surfaced for reviewer):

  • buildSpendCurve CPM formula produces Infinity if a custom fixture sets cpm: 0 (no seeded product does today)
  • forecast_range_unit cast from string — widened to all 8 enum values rather than guarded at runtime; adequate for an example file

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 adcp#3121
for context.

Session: https://claude.ai/code/session_01Qf2uPL7iSb54kgCRiXUtzP


Generated by Claude Code

claude added 3 commits May 3, 2026 01:04
- Remove invalid ReturnType generic annotation on createMediaBuy
- Make generated_at deterministic via seedToTimestamp() in both forecast builders
- Fix status: 'active' as const on sync approval path
- Fix OpenAPI $ref + sibling description via allOf
- FIXME → TODO for adopter comment

https://claude.ai/code/session_01Qf2uPL7iSb54kgCRiXUtzP
- Handle total_budget as { amount, currency } object (AdCP 3.x shape)
- Replace "field names match" comment with explicit field-by-field mapping;
  note valid_until omission and SWAP hint
- Expand forecast_range_unit cast to all eight ForecastRangeUnit values
- Add /_debug/traffic curl line to demo block
- SWAP → FIXME(adopter) in getMediaBuys and updateMediaBuy stubs

https://claude.ai/code/session_01Qf2uPL7iSb54kgCRiXUtzP
@bokelley

bokelley commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1414, which has broader scope: covers both #1375 + #1378 (sales-guaranteed AND sales-social planning surface), wires the new endpoints into the existing 788-line hello_seller_adapter_guaranteed.ts from #1373, adds 24 tests + comply_test_controller wiring + cascade-scenario coverage, and files three SDK follow-ups (#1415, #1416, #1417) for the gaps the cascade work uncovered.

@bokelley bokelley closed this May 3, 2026
@bokelley

bokelley commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

Acknowledged — noted that this PR is superseded by #1414. No further action needed here.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mock-server: sales-guaranteed mock should expose forecast/availability endpoints (GAM-shape)

2 participants