Skip to content

fix(training-agent): echo package context on the inventory tenants - #9143

Merged
bokelley merged 1 commit into
mainfrom
fix/inventory-package-context-echo
Nov 20, 2026
Merged

bokelley merged 1 commit into
mainfrom
fix/inventory-package-context-echo

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Why

Staging certification runs 167 (inventory-adserver) and 168 (inventory-content) failed every buy family on the same check:

The seller did not echo the context unchanged on: create_media_buy (package context).

The buyer sends each package with a package-level context (correlation values). The inventory tenants' create_media_buy and get_media_buys package rows came back without it. static/schemas/source/core/package.json defines context as "Opaque package-level correlation data echoed unchanged in responses, webhooks, and read surfaces", and media-buy/package-request.json says the same on the request side.

What

In server/src/training-agent/inventory-sim/:

  • create_media_buy stores each package's context exactly as sent, as a structured clone.
  • update_media_buy replaces a package's stored context when the update sends one, and lists that package among affected_packages.
  • Every package row the tenants return (create_media_buy, update_media_buy and get_media_buys) echoes the stored context unchanged. It is never read for business logic.

get_media_buy_delivery's by_package rows have no context field in the schema, so they're unchanged.

Compliance coverage

Storyboards already assert the package-context echo: pending_creatives_to_start, inline_creatives_without_sync and package_correlation_legacy_fallback check packages[0].context.buyer_ref on create and read-back. The inventory tenants simply aren't in the training-agent storyboard CI matrix, so nothing graded them. Adding them is a separate, larger change.

Tests

training-agent-inventory-tenants: 23/23. The new case sends a nested context (strings, numbers, null, false, arrays) and checks it comes back identical:

  • on create_media_buy;
  • on get_media_buys;
  • on update_media_buy's affected_packages, with a replacement context;
  • on re-read after the update.

The responses validate against the canonical schemas, and the type check is clean.

🤖 Generated with Claude Code

Staging certification of both inventory tenants failed every buy family
with "The seller did not echo the context unchanged on: create_media_buy
(package context)". core/package.json requires sellers to preserve a
package's context unchanged in responses and read surfaces; the
inventory tenants dropped it.

Store each package's context as sent on create_media_buy, replace it when
update_media_buy sends one, and echo it on create_media_buy,
update_media_buy and get_media_buys package rows. It is never read for
business logic.

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

@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 app-only fix for the training-agent inventory simulator.

Checked:

  • Scope is server/src/training-agent/** plus a unit test — app code only, not the published protocol surface (static/schemas/source/**, docs/reference/**, dist artifacts, task defs). No changeset required; no schema↔docs drift; no dist-artifact mutation.
  • Change adds an opaque package-level context echo, implementing the existing core/package.json field. Writes store defensive structuredClones guarded by isContext; reads echo via wirePackage across create, update affected_packages, and get_media_buys.
  • New test covers create/read/update/re-read with nested data.
  • No oneOf, transport/auth/signing, or breaking-class protocol change; no governance-precedent conflict.

Decision table: no critical/high/medium findings; gated_paths false; high_risk false; no no-auto-approve team match. Rows 1–8 do not fire → row 9 approve. (review_decision: REVIEW_REQUIRED does not block since gated_paths is false.)

@bokelley
bokelley merged commit 2b8884d into main Nov 20, 2026
56 checks passed
@bokelley
bokelley deleted the fix/inventory-package-context-echo branch November 20, 2026 22:00
KonstantinMirin added a commit to KonstantinMirin/adcp that referenced this pull request Nov 21, 2026
Brings in 23 commits from main, among them the 3.2.12 hosted registration,
the @adcp/sdk 17.0.0-beta.31 bump (adcontextprotocol#9132), the inventory-tenant creative
library (adcontextprotocol#9116, adcontextprotocol#9143), the macOS runner tools for the release tests (adcontextprotocol#9138)
and the hook split in adcontextprotocol#9126.

The hooks stay as this branch has them: pre-commit runs the root suite, the
staged-file-scoped server suite, the checks and the node:test files as one
vitest run under a 120 s budget, and pre-push runs the storyboard queue under
180 s. With the shared workers, caches and queue, both fit in about 200 s on
an M4 Pro, so this branch keeps the suites in the hooks. adcontextprotocol#9126's additive
pieces stay: npm run verify:local and precommit-server-unit.cjs --full.

Resolution ledger:
- mechanical: package-lock.json -> main's (identical to main after the merge).
- semantic:
  - package.json -> this branch's precommit script, plus main's verify:local.
  - .husky/pre-push (auto-merged) -> this branch's storyboard block; the
    matrix runs when its sources change, ADCP_SKIP_STORYBOARD_MATRIX=1 skips it.
  - .agents/playbook.md -> this branch's Local Hooks text, plus a
    verify:local paragraph; main's auto-merged hook description removed.
  - scripts/precommit-server-unit.cjs -> union: main's --full switch runs
    this branch's single-run full plan.
  - scripts/verify-local.cjs -> main's, with its header no longer saying the
    hooks run only fast checks.
  - server/tests/unit/training-agent-inventory-tenants.test.ts -> union:
    main's new cases with this branch's static import and state resets.
  - tests/cdn-artifacts, changesets-fence, maintenance-release-publication,
    release-publication-ordering -> union: this branch's git-env isolation,
    main's runnerPath() as the one GNU-tools mechanism; this branch's
    tests/helpers/gnu-tools.cjs and its shims are removed as unused.
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