feat: Add TIME pricing model for duration-based sponsorships#1021
Merged
Conversation
Add a new `time` pricing model that charges per time unit (hour, day, week, or month), enabling self-serve sponsorship buys where total cost scales with campaign duration. This complements `flat_rate` which represents a fixed total cost regardless of duration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bokelley
added a commit
that referenced
this pull request
Apr 26, 2026
* feat(training-agent): GCP KMS-backed webhook signing Routes the training-agent's outbound webhook signing through a GCP KMS SigningProvider (5.21.0 surface added per upstream issue #1020 / PR #1021). Private webhook-signing key material no longer enters process memory in production. AdCP requires distinct key material per signing purpose (docs/guides/SIGNING-GUIDE.md § Key separation), so this provisions a second KMS cryptoKeyVersion separate from the request-signing key. New Fly secret: GCP_KMS_WEBHOOK_KEY_VERSION. The shared GCP_SA_JSON covers IAM for both. Refactors server/src/security/gcp-kms-signer.ts into a factory pattern: - getRequestSigningProvider() — outbound AdCP request signing - getWebhookSigningProvider() — webhook signing Shared init / tripwire / lazy-singleton / in-flight-dedup logic. expected-public-key.ts now exports both committed PEMs and KIDs: - aao-signing-2026-04 (request-signing) - aao-webhook-2026-04 (webhook-signing) The published JWKS at /.well-known/jwks.json advertises both keys with their respective adcp_use values; receivers enforce purpose at that field per the AdCP spec. training-agent/webhooks.ts: - New synchronous SigningProvider wrapper that exposes the static wire identity (keyid/algorithm/fingerprint from constants) immediately and defers KMS resolution to first sign() call. Lets createAdcpServer's sync `webhooks` config accept a provider whose KMS round-trip hasn't happened yet. - New getWebhookSigningMaterial() returning the discriminated SDK shape (signerKey | signerProvider). - Dev fallback unchanged: ephemeral key generation or WEBHOOK_SIGNING_KEY_JWK when KMS env unset. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(webhooks): preserve deriveWebhookOperationId structured key format The earlier rewrite of training-agent/webhooks.ts replaced the structured operation_id (`${principal}|${toolName}.${entityId}`) with a hex hash — the existing tests in server/tests/unit/training-agent-webhook-operation-id.test.ts assert on the structured format (e.g. 'p|create_media_buy.mb_1') and broke. Restored main's webhooks.ts as the base and surgically added only the KMS path on top: - Imports for getWebhookSigningProvider + WEBHOOK_SIGNING_KID/PEM - KMS_WEBHOOK_ENV constant, WebhookMaterial discriminated union - buildKmsWebhookProviderWrapper(): sync SigningProvider that defers KMS resolution to first sign() call so createAdcpServer's sync webhooks config can take a provider whose KMS init hasn't happened - ensureMaterial() picks KMS when GCP_KMS_WEBHOOK_KEY_VERSION set, otherwise falls back to existing ephemeral / WEBHOOK_SIGNING_KEY_JWK - getWebhookSigningMaterial() returns { signerKey } or { signerProvider } - getPublicJwks/getWebhookEmitter use the discriminated material deriveWebhookOperationId, generateEphemeralKey, loadConfiguredKey, the TOOL_TO_PROTOCOL map, and all other surface preserved verbatim. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #930
timepricing model to support sponsorship deals priced per time unit (hour, day, week, month)fixed_pricex number of time units in the campaign flightflat_rate(fixed total cost) with duration-based pricing that lets buyers self-serve any campaign lengthmin_duration/max_durationconstraintsChanges
New schema:
static/schemas/source/pricing-options/time-option.jsonUpdated schemas:
pricing-model.jsonenum — added"time"pricing-option.jsononeOf — added$refto time-optionindex.jsonregistry — added time-option entryUpdated docs:
pricing-models.mdx— full Time section with example, parameters, calculation table, comparison with flat ratemedia-products.mdx— added Time to supported models list, fixed CPA naming inconsistency, removed phantom CPL entryIndustry alignment
CPD(Cost Per Day) CostType for Sponsorship line itemsCPDRateTypeTest plan
🤖 Generated with Claude Code