Repository navigation
feat(training-agent): inventory-adserver tenant over the delivery engine (#9025) - #9038
Conversation
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — training-agent-only feature (new inventory-adserver tenant over the sim engine). No touch to static/schemas/source/, docs/reference/, dist/**, or package.json version; changeset correctly omitted (training-agent is out of published-protocol scope). storyboardCompat 3.0 gating verified consistent across index.ts and registry.ts; optional-tenant registration isolation confirmed.
Medium findings (1):
- server/src/training-agent/inventory-sim/platform.ts:274 — Lost-update race in per-caller market store (duplicate media_buy_id, dropped booking under concurrent same-principal requests)
With 1 medium finding, no critical/high, gated_paths false, high_risk false, no team gate, and no prior escalation, none of rows 1–8 fire. Falls through to row 9 → approve. The race is worth a follow-up but is non-blocking per the decision table.
Medium findings
- server/src/training-agent/inventory-sim/platform.ts:274 — Lost-update race in per-caller market store (duplicate media_buy_id, dropped booking)
60383cc to
a16afe0
Compare
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — training-agent inventory-sim work only, no protocol surface touched.
Checked:
- All 8 delta files reviewed (== full PR). No Critical/High findings.
- platform.ts createMediaBuy verified fail-fast: a mid-batch engine error throws before market.save(), mutating only a discarded structuredClone, so no partial booking persists. buyStatus/delivery/pacing and account scoping check out.
- registry.ts optional-register fallback correctly isolates inventory-tenant registration failure.
- No
static/schemas/source/**ordocs/reference/**changes → no changeset required, no schema↔docs/oneOf/artifact-immutability concerns. - gated_paths: false; review_decision APPROVED; no no-auto-approve team match; high_risk: false.
Medium findings (1):
- server/src/training-agent/inventory-sim/market-store.ts:103 — Lost-update race in per-caller market store (duplicate ids, dropped booking). This is the prior run's finding, now re-pinned to its real site.
With 1 medium finding, no escalation trigger, and no team/gate block, this falls through to row 9 (approve). The single medium is a carried-over concurrency note on a training-agent simulation path, not a blocker.
Medium findings
- server/src/training-agent/inventory-sim/market-store.ts:103 — Lost-update race in per-caller market store (duplicate ids, dropped booking)
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — app-only training-agent change (new /inventory-adserver tenant over the sim engine); no protocol surface touched, so the no-changeset decision is correct, and responses validate against canonical AdCP schemas in the new test suite.
Medium findings
- server/src/training-agent/inventory-sim/platform.ts:498 — Lost-update race in per-caller market store: openMarket clones after an await and save() writes the clone whole, so two concurrent writes from the same caller can lose an update (duplicate media_buy_id, dropped booking).
This is the same single medium finding re-surfaced from the prior run (line shifted from 274 to 498). The reviewer verified createMediaBuy's partial-failure rollback, account_id isolation on all read paths, and the optional-registration fix are all sound. With one medium finding, no critical/high, no gated-path or team-gate trigger, high_risk false, and review_decision APPROVED, this falls through to row 9.
Medium findings
- server/src/training-agent/inventory-sim/platform.ts:498 — Lost-update race in per-caller market store (duplicate media_buy_id, dropped booking)
The base branch was changed.
…ine (#9025) Part B of #9025, slice 2: a simulated ad server inventory agent at /inventory-adserver/mcp, serving the engine's adserver-2027 seed. - get_products returns the seed's products with engine forecasts for the requested flight (filters.start_date/end_date, default 30 days), narrowed by filters.countries, delivery_type and channels. - create_media_buy books each package into the caller's market: guaranteed packages take an impression goal (or what the budget buys), the takeover takes share of voice, auction packages bid above the floor. update_media_buy pauses, cancels and changes budget, goal, bid and end time. get_media_buys and get_media_buy_delivery read the bookings; delivery is released at each product's reporting lag. - One market per caller and tenant, kept beside the caller's sandbox document in the session store and caught up to the caller's sandbox clock on every call. - Mounted beside the other tenants but outside TENANT_IDS, so brand.json, adagents.json and the /mcp-strict routes are unchanged; not served on the 3.0 compat route. A failed inventory registration is logged and leaves the other tenants up. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… clock (#9025) Review on #9042: a caller's sandbox clock is shared by every tenant, and any tenant's reset_state unpins it (back to the wall clock). A market that had already run days the clock now has not reached would keep its buys but report no delivery, since every recorded day lies in the clock's future. Such a market belongs to the discarded timeline, so openMarket and advanceMarket now start it fresh, as they do for a changed seed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
a16afe0 to
3846d7b
Compare
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — app/training-agent change with no blocking findings.
This is a subsequent review (prior decision: approve) of the full inventory-tenant PR (delta == full, 8 files). The new code is clean: registry optional-tenant isolation keeps a failed inventory tenant from taking down others, correct 3.0-compat gating in index.ts/registry.ts, per-principal+per-account market isolation, atomic-on-failure booking, and tests validate responses against the canonical AdCP 3.2 schemas. This is an app/training-agent change (not a static/schemas/source/** wire change), so no changeset is required per repo conventions.
Medium findings (non-blocking):
- server/src/training-agent/inventory-sim/platform.ts:498 — Lost-update race in per-caller market store (duplicate media_buy_id, dropped booking)
Only one medium finding (not a data-loss/schema/infra escalation category in this app context, not on a modified high-risk path). No critical/high. high_risk is false; gated_paths is false. Author is not on a no-auto-approve team. With a single medium finding and no escalation trigger, rows 1–8 do not fire — falls through to row 9: approve. The prior escalation sticky rule (row 6) does not apply (prior was approve).
Medium findings
- server/src/training-agent/inventory-sim/platform.ts:498 — Lost-update race in per-caller market store (duplicate media_buy_id, dropped booking)
…ck (#9025) Review on #9042 and #9038: - reset_state on an inventory tenant unpins the caller's sandbox clock, which every tenant shares, so it now discards the caller's market on every inventory tenant, not only the one it was called on. - sandbox_clock now advances only the market of the tenant it is called on, so its write stays under the router's lock for that tenant (which serializes a tenant's requests from transport through session flush). The caller's other markets run the same days on their next read, with the same results. The response reports days_crossed, the UTC days the clock moved across, instead of days_run. - A test unpins the clock the way /sales reset_state does and shows the inventory market starting fresh rather than reporting nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…#9025) (#9039) * feat(training-agent): sandbox_clock scenario on the inventory tenants (#9025) Part A of #9025, scoped to the inventory tenants: a comply_test_controller scenario that reads and moves the caller's one sandbox clock. { "scenario": "sandbox_clock", "params": { "operation": "get" } } { "scenario": "sandbox_clock", "params": { "operation": "advance_time", "to": "2027-01-15T00:00:00Z" } } { "scenario": "sandbox_clock", "params": { "operation": "advance_time", "by": "P30D" } } - It moves the same per-caller simulated_now that reporting_subscription_probe advance_time moves, so there is one clock. It only moves forward, refuses months and years in durations, and is listed in list_scenarios and compliance_testing.scenarios. - Advancing catches up every inventory market the caller has (the engine's day steps for each day crossed) and runs the same post-advance hooks as the probe (runSandboxClockAdvanceHooks). - reset_state on an inventory tenant unpins the clock, as the probe's reset does, and discards the caller's market on that tenant. - The router answers sandbox_clock and list_scenarios for the inventory tenants, because the SDK's controller config has no slot for a scenario of our own; reset_state goes through the SDK. - Tests only: setSandboxWallClockForTesting moves where an unpinned clock starts, so the seeds' scripted 2027 events stay reachable whenever the suite runs. The existing probes and tenants are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(training-agent): reset every inventory market with the shared clock (#9025) Review on #9042 and #9038: - reset_state on an inventory tenant unpins the caller's sandbox clock, which every tenant shares, so it now discards the caller's market on every inventory tenant, not only the one it was called on. - sandbox_clock now advances only the market of the tenant it is called on, so its write stays under the router's lock for that tenant (which serializes a tenant's requests from transport through session flush). The caller's other markets run the same days on their next read, with the same results. The response reports days_crossed, the UTC days the clock moved across, instead of days_run. - A test unpins the clock the way /sales reset_state does and shows the inventory market starting fresh rather than reporting nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
The post-deploy smoke now probes /inventory-adserver/mcp and /inventory-content/mcp, the two simulated inventory tenants merged in #9038 and #9040. An inventory tenant that fails to register is logged and left down without affecting the others, so without this probe a production-only registration failure would go unnoticed; with it, the deploy fails like any other tenant's. Split out of #9041 so the docs can land without the .github/workflows review gate. Co-authored-by: Claude Opus 5.5 <[email protected]>
Part B of #9025, slice 2 of 5. This PR adds a simulated ad server inventory agent at
/inventory-adserver/mcp, serving the engine'sadserver-2027seed. It is stacked on #9037, so the diff shows this slice only.get_products:filters.start_dateandfilters.end_date. The default flight is the next 30 days.filters.countriesnarrows the forecast;delivery_typeandchannelsfilter the products.cache_scopeisaccount, because forecasts subtract the caller's own bookings.create_media_buybooks each package into the caller's simulated market:impressionsas its goal. Without one, the goal is what the budget buys at the fixed price.bid_priceabove the floor.targeting_overlay.geo_countriesnarrows a package.PRODUCT_NOT_FOUND, and a wrong pricing option withINVALID_PRICING_OPTION.update_media_buypauses, resumes and cancels, and changes a package's budget, goal or bid, or the buy's end time. It honoursrevision(CONFLICTon a mismatch).get_media_buysandget_media_buy_deliveryread back the bookings. Delivery includesby_packageanddaily_breakdownrows, andpacing_indexfor guaranteed packages.Keeping existing tenants unchanged
TENANT_IDS. Sobrand.json,adagents.json, the/mcp-strictroutes and the tenant-listing tests are unchanged. It is not served on the 3.0 compatibility route./salesincluded.product-factory.tsgains an exportedformatOptionsForTrainingFormats, so the seeds' format labels map to canonicalformat_options.Tests
server/tests/unit/training-agent-inventory-tenants.test.tsboots the router and calls the tenant over MCP. Every response is checked againstgetCanonicalToolValidator(tool, 'sync', { adcpVersion: '3.2' }).brand.jsonand tool dispatch (tool-catalog drift needed a rerun on its own after a timeout under load);tenant-smoke.test.tsandserved-release-shape.test.ts.Checks run locally
npx tsc --project server/tsconfig.json --noEmit: clean.tests/lint-format-identity-boundaries.test.cjs: passes.server/tests/unit/inventory-sim-engine.test.tsandserver/tests/unit/training-agent-inventory-tenants.test.ts(run from the repo root): pass.Committed and pushed with
HUSKY=0, which @bokelley approved for this series. Under host load of 40 to 80, the pre-commit server unit suite timed out in unrelated suites (addie/matched-pair-ni/exact-inference). A local storyboard matrix run against the stack's tip was stopped after 66 minutes, by which point/signalshad passed (57 clean against a floor of 45). CI's storyboard job is the check that existing storyboards still pass.No changeset: this touches only the training agent and docs, not the protocol surface.
Refs #9025, #8993
🤖 Generated with Claude Code