Skip to content

feat(training-agent): inventory-content tenant with scheduled installments (#9025) - #9040

Merged
bokelley merged 2 commits into
mainfrom
inventory-sim/content-tenant
Nov 15, 2026
Merged

bokelley merged 2 commits into
mainfrom
inventory-sim/content-tenant

Conversation

@bokelley

@bokelley bokelley commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Part B of #9025, slice 4 of 5. This PR adds a simulated content platform inventory agent at /inventory-content/mcp, serving the engine's content-2027 seed: a weekly podcast, a weekly newsletter and a fortnightly creator series. It is stacked on #9039.

  • What a product is: an exclusive sponsorship of one collection.
  • get_products carries the product's collections, and the installments scheduled in the requested flight. Each installment's status is as known at the caller's sandbox time: scheduled, then published, postponed (with the new scheduled_at) or cancelled once its date passes.
  • What a package buys: every installment of its product scheduled in its flight. AdCP sells installments through the product, and collection_selection picks collections, not single episodes.
  • Delivery after the flight: a package keeps serving until its installments' audience has built up over the channel's curve, plus a two-week allowance for postponements. A second sponsor of the same installments is refused with PRODUCT_UNAVAILABLE.
  • Forecast versus delivery: the forecast counts each installment's expected audience; delivery counts only what ran.

Tests

  • Cancelled episode: sponsor the podcast for January, which covers four episodes, one of them episode 012. Checked:
    • episode 012 shows scheduled before 2027-01-18 and cancelled after;
    • the forecast for those episodes drops to 0 once they are booked;
    • by mid-March, delivery is 60–90% of the forecast, because three of the four episodes ran;
    • listens start on the first episode's date and keep arriving into late February.
  • Postponed video: maker_studio_006 reports scheduled_at 2027-01-23.

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.ts and server/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 /signals had 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

@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 — app-only training-agent PR adding the /inventory-content tenant (podcast/newsletter/creator sponsorships over installments).

What I checked:

  • Scope: touches only server/src/training-agent/** and its test. No static/schemas/source/**, docs/reference/**, or dist/** changes, so no changeset is required and no schema↔docs coherence, oneOf, or artifact-immutability concerns apply.
  • Reviewer verified installmentsIn day-window bounds match the engine's flightDays, the known.get(...)! non-null is safe (filtered set is always a subset), the zeroed-forecast branch drops only non-surfaced fields, and the 14-day postponement allowance covers current seeds.
  • Deterministic in-memory engine, no external I/O — timeout/retry checks N/A.

No blocking findings. Two Low follow-ups noted (order-coupled tests that fail loud if reordered; 14-day allowance truncating any future >14-day postponement seed) — non-blocking.

Gate checks: no no-auto-approve team match; gated_paths false; high_risk false; no prior decision; zero findings. Rows 1–8 do not fire → row 9 approve.

@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 inventory-simulator code.

Checked:

  • No findings from the reviewer (no critical/high/medium).
  • Diff (4 files, +157/-10) is entirely training-agent inventory-simulator code: the new /inventory-content tenant for installment (podcast/newsletter/creator) sponsorships plus its unit tests.
  • No protocol surface touched (no static/schemas/source/**, docs/reference/**, dist/**, or package.json), so no changeset, wire-shape, oneOf, or immutability concerns apply.
  • Verified non-null lookups in platform.ts wireInstallments are sound, the audienceEndMs Math.max(...) is guarded against empty arrays, and new behavior is covered by sell/cancel/delivery-build, cross-tenant reset_state, and postponed-installment tests.

Decision table: no critical/high (row 1 n/a); gated_paths false (row 2 n/a); high_risk false (rows 3/5 n/a); no medium findings (rows 4/8 n/a); no no-auto-approve team match (row 7 n/a); prior decision was approve (row 6 n/a). Falls through to row 9 → approve.

aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Nov 15, 2026

@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 inventory-sim code.

The 284-line delta across 4 files is entirely training-agent inventory-sim code (platform.ts installment/sponsorship wiring, two tenant registration files, and a unit test). No protocol schema, docs/reference, dist artifacts, or changeset surface is touched, so no spec-drift, changeset-scope, oneOf-discriminator, or artifact-immutability concerns apply.

Reviewer verified: known.get(id)! assertions in wireInstallments are provably safe (statuses sourced from the full productInstallments set), the empty-installments branch zeroes every metric toAdcpForecast reads, installmentsIn's ceil-based exclusive end bound is correct, and the flight_end→audienceEndMs extension matches the tests. Registration files mirror existing inventory-adserver entries.

No Critical/High/Medium findings. high_risk=false, gated_paths=false (and review_decision=APPROVED regardless), no no-auto-approve team match. Prior decision was also approve with no findings. Rows 1–8 do not fire → row 9 approve.

@bokelley
bokelley force-pushed the inventory-sim/sandbox-clock branch from 8c7e6bc to 84be9e3 Compare November 15, 2026 21:19
Base automatically changed from inventory-sim/sandbox-clock to main November 15, 2026 22:01
@bokelley
bokelley dismissed aao-secretariat[bot]’s stale review November 15, 2026 22:01

The base branch was changed.

bokelley and others added 2 commits November 15, 2026 22:02
…ments (#9025)

Part B of #9025, slice 4: a simulated content platform inventory agent at
/inventory-content/mcp, serving the engine's content-2027 seed (a weekly
podcast, a weekly newsletter and a fortnightly creator series).

- Each product is an exclusive sponsorship of one collection. get_products
  carries the product's collections and the installments scheduled in the
  requested flight, with their status as known at the caller's sandbox
  time: scheduled, then published, postponed (with the new date) or
  cancelled once the date passes.
- A package buys every installment of its product scheduled in its flight,
  and serves until their audience has built up over the channel's curve
  (newsletter 3 days, podcast 30, video 42) plus a two-week allowance for
  postponement. A second sponsor of the same installments is refused as
  PRODUCT_UNAVAILABLE.
- The forecast counts each installment's expected audience; delivery
  counts what ran, so the seed's cancelled 2027-01-18 episode delivers
  nothing and its postponed 2027-01-18 video delivers from 2027-01-23.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… their own clock (#9025)

- reset_state on /inventory-content discards the caller's
  /inventory-adserver market too (the shared clock it unpins would leave
  that market on a discarded timeline).
- The postponed-installment test now moves the clock itself instead of
  relying on the clock an earlier test left behind (Ladon low on #9040).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bokelley
bokelley force-pushed the inventory-sim/content-tenant branch from b12525b to 2482a2d Compare November 15, 2026 22:03

@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 — adds the /inventory-content training tenant (sponsorship sales over scheduled collection installments) plus platform wiring. 4 files, 157 net lines.

Checks performed:

  • platform.ts wireInstallments (L53) non-null assertion is safe: installmentStatuses maps the same productInstallments list that installmentsIn filters, so every installment is present. audienceEndMs Math.max(...ends) (L46) never runs on empty — empty installments route to the zeroed-forecast branch (L84) and the booking path throws first (L121). Fail-closed.
  • POSTPONEMENT_ALLOWANCE_DAYS = 14 is a documented sim approximation, not a contract.
  • No static/schemas/source/**, dist/**, docs/reference, or oneOf surface touched — training-agent is app/operational, so no changeset required.
  • Deterministic sim internals, no external I/O/workers/queues.
  • Tests cover sell/cancel/postpone/delivery-build and cross-tenant reset_state isolation.

No critical/high/medium findings. gated_paths false; no high-risk flag; no no-auto-approve team match. Although review_decision is REVIEW_REQUIRED, row 2 only applies when gated_paths is true (it is false here), so the PR falls through to row 9. Consistent with the prior approve on this PR.

@bokelley
bokelley merged commit b300ec6 into main Nov 15, 2026
56 checks passed
@bokelley
bokelley deleted the inventory-sim/content-tenant branch November 15, 2026 22:47
bokelley added a commit that referenced this pull request Nov 16, 2026
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]>
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