Skip to content

fix(training-agent): inventory create_media_buy refuses a flight that starts before today - #9154

Draft
bokelley wants to merge 1 commit into
mainfrom
fix/inventory-past-start
Draft

bokelley wants to merge 1 commit into
mainfrom
fix/inventory-past-start

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

On the inventory tenants (/inventory-adserver, /inventory-content), create_media_buy booked a flight whose start_time was years in the past. schema_validation's create_buy_past_start_reject expects INVALID_REQUEST.

The new rule:

  • A buy or package start_time before the start of the caller's current sandbox day (UTC) is refused, with INVALID_REQUEST on that start_time field.
  • A start any time earlier today is accepted. The engine books whole days, so it books the same flight as now. Storefronts also commonly send today's midnight as the start.
  • "Today" is the caller's sandbox clock. A caller who has advanced the clock is checked against simulated time, not the wall clock.
  • "asap" is unchanged.

This is the second quick gap found when #9150's seed_* scenarios let schema_validation run on these tenants. Today's CI doesn't run that storyboard here, so no floor moves; #9150's floors will include this fix.

Draft until the R&D coordinator confirms that the Apostra certification never books with a start before the current day.

Test plan

  • New test: a 2020 start answers INVALID_REQUEST on start_time, and a start at today's midnight books. It fails without the fix: the 2020 flight was booked.
  • Inventory suite: 26/26, including the flows that book after advancing the sandbox clock.

🤖 Generated with Claude Code

… starts before today

A buy or package start_time years in the past was booked. Refuse a start
before the caller's current sandbox day (UTC) with INVALID_REQUEST on that
start_time field (schema_validation/create_buy_past_start_reject). A start
earlier today is accepted: the engine books whole days, so it books the same
flight as now, and storefronts commonly send today's midnight.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bokelley

Copy link
Copy Markdown
Contributor Author

Parked: this stays a draft for now.

This PR refuses a start before the caller's sandbox day. The Apostra storefront has no sandbox clock: it always books on wall time (buys start at now; its create-without-creatives probe starts a few hours ahead). So once a caller's sandbox clock runs ahead of wall time, every buy Apostra sends on that caller's token would be refused as a past start.

  • Public token: the storefront's staging certification runs on the shared public token. Any other tester who advances that token's clock would break it.
  • Month-long simulation: those runs advance the clock and book through Apostra, so they would hit this on day 2.

Unblocks when the storefront uses its own demo token, and a decision is made on how a wall-time client books against a caller whose sandbox clock is ahead. Options include checking against wall time when the clock is pinned ahead, or a grace window, or Apostra reading the sandbox clock.

The storyboard gap it closes (schema_validation / create_buy_past_start_reject) stays a visible failure in the inventory storyboard rows until then.

This branch has not been deployed

No deployments
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.

1 participant