@adcp/sdk 14.0.0-rc.37 → 14.0.0-rc.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/adcp-storyboard-summary.js +286 -0
- package/bin/adcp.js +221 -10
- package/dist/lib/conformance/schemaLoader.d.mts +1 -1
- package/dist/lib/conformance/schemaLoader.d.ts +1 -1
- package/dist/lib/core/AgentClient.d.mts +6 -1
- package/dist/lib/core/AgentClient.d.ts +6 -1
- package/dist/lib/core/AgentClient.js +9 -0
- package/dist/lib/core/AgentClient.mjs +9 -0
- package/dist/lib/core/ConversationTypes.d.mts +29 -0
- package/dist/lib/core/ConversationTypes.d.ts +29 -0
- package/dist/lib/core/SingleAgentClient.d.mts +3 -1
- package/dist/lib/core/SingleAgentClient.d.ts +3 -1
- package/dist/lib/core/SingleAgentClient.js +9 -1
- package/dist/lib/core/SingleAgentClient.mjs +9 -1
- package/dist/lib/core/TaskExecutor.d.mts +13 -1
- package/dist/lib/core/TaskExecutor.d.ts +13 -1
- package/dist/lib/core/TaskExecutor.js +216 -18
- package/dist/lib/core/TaskExecutor.mjs +216 -19
- package/dist/lib/index.d.mts +5 -2
- package/dist/lib/index.d.ts +5 -2
- package/dist/lib/index.js +10 -1
- package/dist/lib/index.mjs +10 -1
- package/dist/lib/media-buy/action-assessment.d.mts +77 -0
- package/dist/lib/media-buy/action-assessment.d.ts +77 -0
- package/dist/lib/media-buy/action-assessment.js +300 -0
- package/dist/lib/media-buy/action-assessment.mjs +284 -0
- package/dist/lib/media-buy/action-constraints.d.mts +9 -0
- package/dist/lib/media-buy/action-constraints.d.ts +9 -0
- package/dist/lib/media-buy/action-constraints.js +170 -0
- package/dist/lib/media-buy/action-constraints.mjs +146 -0
- package/dist/lib/media-buy/action-contracts.d.mts +40 -0
- package/dist/lib/media-buy/action-contracts.d.ts +40 -0
- package/dist/lib/media-buy/action-contracts.js +304 -0
- package/dist/lib/media-buy/action-contracts.mjs +267 -0
- package/dist/lib/media-buy/action-metadata.generated.d.mts +37 -0
- package/dist/lib/media-buy/action-metadata.generated.d.ts +37 -0
- package/dist/lib/media-buy/action-metadata.generated.js +128 -0
- package/dist/lib/media-buy/action-metadata.generated.mjs +101 -0
- package/dist/lib/media-buy/action-types.d.mts +106 -0
- package/dist/lib/media-buy/action-types.d.ts +106 -0
- package/dist/lib/{types/v3-1-beta/tools.generated.js → media-buy/action-types.js} +2 -2
- package/dist/lib/media-buy/actions.d.mts +6 -0
- package/dist/lib/media-buy/actions.d.ts +6 -0
- package/dist/lib/media-buy/actions.js +38 -0
- package/dist/lib/media-buy/actions.mjs +9 -0
- package/dist/lib/media-buy/available-actions.d.mts +2 -1
- package/dist/lib/media-buy/available-actions.d.ts +2 -1
- package/dist/lib/media-buy/available-actions.js +4 -3
- package/dist/lib/media-buy/available-actions.mjs +4 -3
- package/dist/lib/media-buy/compatibility.js +3 -0
- package/dist/lib/media-buy/compatibility.mjs +3 -0
- package/dist/lib/media-buy/index.d.mts +4 -0
- package/dist/lib/media-buy/index.d.ts +4 -0
- package/dist/lib/media-buy/index.js +3 -1
- package/dist/lib/media-buy/index.mjs +1 -0
- package/dist/lib/media-buy/legacy-action-ids.d.mts +1 -0
- package/dist/lib/media-buy/legacy-action-ids.d.ts +1 -0
- package/dist/lib/media-buy/legacy-action-ids.js +50 -0
- package/dist/lib/media-buy/legacy-action-ids.mjs +26 -0
- package/dist/lib/media-buy/mutations.d.mts +70 -0
- package/dist/lib/media-buy/mutations.d.ts +70 -0
- package/dist/lib/media-buy/mutations.js +525 -0
- package/dist/lib/media-buy/mutations.mjs +498 -0
- package/dist/lib/media-buy/preflight.d.mts +20 -69
- package/dist/lib/media-buy/preflight.d.ts +20 -69
- package/dist/lib/media-buy/preflight.js +100 -336
- package/dist/lib/media-buy/preflight.mjs +111 -333
- package/dist/lib/media-buy/targeting-input.d.mts +7 -4
- package/dist/lib/media-buy/targeting-input.d.ts +7 -4
- package/dist/lib/media-buy/types.d.mts +55 -7
- package/dist/lib/media-buy/types.d.ts +55 -7
- package/dist/lib/protocols/rawResponseCapture.d.mts +12 -0
- package/dist/lib/protocols/rawResponseCapture.d.ts +12 -0
- package/dist/lib/protocols/rawResponseCapture.js +33 -3
- package/dist/lib/protocols/rawResponseCapture.mjs +32 -3
- package/dist/lib/registry/types.generated.d.mts +377 -9
- package/dist/lib/registry/types.generated.d.ts +377 -9
- package/dist/lib/reporting/content-mismatch.d.mts +126 -0
- package/dist/lib/reporting/content-mismatch.d.ts +126 -0
- package/dist/lib/reporting/content-mismatch.js +90 -0
- package/dist/lib/reporting/content-mismatch.mjs +66 -0
- package/dist/lib/reporting/evidence.d.mts +1 -0
- package/dist/lib/reporting/evidence.d.ts +1 -0
- package/dist/lib/reporting/evidence.js +32 -3
- package/dist/lib/reporting/evidence.mjs +31 -3
- package/dist/lib/reporting/index.d.mts +3 -1
- package/dist/lib/reporting/index.d.ts +3 -1
- package/dist/lib/reporting/index.js +3 -0
- package/dist/lib/reporting/index.mjs +2 -0
- package/dist/lib/reporting/ledger/handler.d.mts +51 -1
- package/dist/lib/reporting/ledger/handler.d.ts +51 -1
- package/dist/lib/reporting/ledger/handler.js +306 -38
- package/dist/lib/reporting/ledger/handler.mjs +304 -37
- package/dist/lib/reporting/ledger/health.d.mts +12 -0
- package/dist/lib/reporting/ledger/health.d.ts +12 -0
- package/dist/lib/reporting/ledger/health.js +15 -2
- package/dist/lib/reporting/ledger/health.mjs +13 -1
- package/dist/lib/reporting/ledger/index.d.mts +3 -0
- package/dist/lib/reporting/ledger/index.d.ts +3 -0
- package/dist/lib/reporting/ledger/index.js +7 -1
- package/dist/lib/reporting/ledger/index.mjs +3 -0
- package/dist/lib/reporting/ledger/lifecycle.d.mts +31 -4
- package/dist/lib/reporting/ledger/lifecycle.d.ts +31 -4
- package/dist/lib/reporting/ledger/lifecycle.js +244 -37
- package/dist/lib/reporting/ledger/lifecycle.mjs +244 -37
- package/dist/lib/reporting/ledger/managed-postgres.d.mts +231 -0
- package/dist/lib/reporting/ledger/managed-postgres.d.ts +231 -0
- package/dist/lib/reporting/ledger/managed-postgres.js +1797 -0
- package/dist/lib/reporting/ledger/managed-postgres.mjs +1776 -0
- package/dist/lib/reporting/ledger/managed.d.mts +355 -0
- package/dist/lib/reporting/ledger/managed.d.ts +355 -0
- package/dist/lib/reporting/ledger/managed.js +661 -0
- package/dist/lib/reporting/ledger/managed.mjs +633 -0
- package/dist/lib/reporting/ledger/notification-activity.d.mts +222 -0
- package/dist/lib/reporting/ledger/notification-activity.d.ts +222 -0
- package/dist/lib/reporting/ledger/notification-activity.js +1139 -0
- package/dist/lib/reporting/ledger/notification-activity.mjs +1110 -0
- package/dist/lib/reporting/ledger/postgres.d.mts +161 -1
- package/dist/lib/reporting/ledger/postgres.d.ts +161 -1
- package/dist/lib/reporting/ledger/postgres.js +1153 -21
- package/dist/lib/reporting/ledger/postgres.mjs +1152 -21
- package/dist/lib/reporting/ledger/producer.d.mts +8 -0
- package/dist/lib/reporting/ledger/producer.d.ts +8 -0
- package/dist/lib/reporting/ledger/producer.js +146 -52
- package/dist/lib/reporting/ledger/producer.mjs +146 -51
- package/dist/lib/reporting/ledger/types.d.mts +358 -1
- package/dist/lib/reporting/ledger/types.d.ts +358 -1
- package/dist/lib/reporting/ledger/types.js +3 -0
- package/dist/lib/reporting/ledger/types.mjs +2 -0
- package/dist/lib/reporting/reconciliation.d.mts +362 -2
- package/dist/lib/reporting/reconciliation.d.ts +362 -2
- package/dist/lib/reporting/reconciliation.js +1051 -7
- package/dist/lib/reporting/reconciliation.mjs +1053 -7
- package/dist/lib/reporting/service/conformance.d.mts +35 -0
- package/dist/lib/reporting/service/conformance.d.ts +35 -0
- package/dist/lib/reporting/service/conformance.js +89 -0
- package/dist/lib/reporting/service/conformance.mjs +68 -0
- package/dist/lib/reporting/service/index.d.mts +182 -0
- package/dist/lib/reporting/service/index.d.ts +182 -0
- package/dist/lib/reporting/service/index.js +793 -0
- package/dist/lib/reporting/service/index.mjs +787 -0
- package/dist/lib/reporting/source/index.d.mts +2 -1
- package/dist/lib/reporting/source/index.d.ts +2 -1
- package/dist/lib/reporting/source/index.js +16 -3
- package/dist/lib/reporting/source/index.mjs +12 -1
- package/dist/lib/reporting/source/inline.d.mts +88 -1
- package/dist/lib/reporting/source/inline.d.ts +88 -1
- package/dist/lib/reporting/source/inline.js +1161 -163
- package/dist/lib/reporting/source/inline.mjs +1166 -163
- package/dist/lib/reporting/source/manifest.js +12 -7
- package/dist/lib/reporting/source/manifest.mjs +12 -7
- package/dist/lib/reporting/source/source.d.mts +26 -0
- package/dist/lib/reporting/source/source.d.ts +26 -0
- package/dist/lib/reporting/source/source.js +71 -2
- package/dist/lib/reporting/source/source.mjs +65 -1
- package/dist/lib/schemas/index.d.mts +22 -1
- package/dist/lib/schemas/index.d.ts +22 -1
- package/dist/lib/schemas/index.js +7 -0
- package/dist/lib/schemas/index.mjs +7 -0
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/create-adcp-server.d.mts +18 -0
- package/dist/lib/server/create-adcp-server.d.ts +18 -0
- package/dist/lib/server/create-adcp-server.js +52 -2
- package/dist/lib/server/create-adcp-server.mjs +52 -2
- package/dist/lib/server/decisioning/account.d.mts +1 -1
- package/dist/lib/server/decisioning/account.d.ts +1 -1
- package/dist/lib/server/decisioning/index.d.mts +1 -0
- package/dist/lib/server/decisioning/index.d.ts +1 -0
- package/dist/lib/server/decisioning/platform.d.mts +3 -0
- package/dist/lib/server/decisioning/platform.d.ts +3 -0
- package/dist/lib/server/decisioning/runtime/from-platform.js +88 -10
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +88 -10
- package/dist/lib/server/decisioning/specialisms/reporting.d.mts +38 -0
- package/dist/lib/server/decisioning/specialisms/reporting.d.ts +38 -0
- package/dist/lib/{types/v3-1-beta/index.js → server/decisioning/specialisms/reporting.js} +2 -8
- package/dist/lib/server/decisioning/specialisms/reporting.mjs +0 -0
- package/dist/lib/server/index.d.mts +4 -2
- package/dist/lib/server/index.d.ts +4 -2
- package/dist/lib/server/index.js +5 -0
- package/dist/lib/server/index.mjs +4 -0
- package/dist/lib/server/media-buy-action-resolver.d.mts +63 -0
- package/dist/lib/server/media-buy-action-resolver.d.ts +63 -0
- package/dist/lib/server/media-buy-action-resolver.js +297 -0
- package/dist/lib/server/media-buy-action-resolver.mjs +285 -0
- package/dist/lib/server/media-buy-actions.d.mts +7 -8
- package/dist/lib/server/media-buy-actions.d.ts +7 -8
- package/dist/lib/server/media-buy-actions.js +57 -14
- package/dist/lib/server/media-buy-actions.mjs +63 -14
- package/dist/lib/server/notification-subscriptions/index.d.mts +2 -2
- package/dist/lib/server/notification-subscriptions/index.d.ts +2 -2
- package/dist/lib/server/notification-subscriptions/index.js +2 -0
- package/dist/lib/server/notification-subscriptions/index.mjs +2 -0
- package/dist/lib/server/notification-subscriptions/postgres-runtime.d.mts +3 -1
- package/dist/lib/server/notification-subscriptions/postgres-runtime.d.ts +3 -1
- package/dist/lib/server/notification-subscriptions/postgres-runtime.js +1 -0
- package/dist/lib/server/notification-subscriptions/postgres-runtime.mjs +1 -0
- package/dist/lib/server/notification-subscriptions/runtime.d.mts +12 -1
- package/dist/lib/server/notification-subscriptions/runtime.d.ts +12 -1
- package/dist/lib/server/notification-subscriptions/runtime.js +102 -16
- package/dist/lib/server/notification-subscriptions/runtime.mjs +101 -16
- package/dist/lib/server/notification-subscriptions/types.d.mts +104 -1
- package/dist/lib/server/notification-subscriptions/types.d.ts +104 -1
- package/dist/lib/server/webhook-emitter.d.mts +40 -5
- package/dist/lib/server/webhook-emitter.d.ts +40 -5
- package/dist/lib/server/webhook-emitter.js +23 -12
- package/dist/lib/server/webhook-emitter.mjs +23 -12
- package/dist/lib/storage/interfaces.d.mts +14 -2
- package/dist/lib/storage/interfaces.d.ts +14 -2
- package/dist/lib/testing/compliance/comply.d.mts +9 -3
- package/dist/lib/testing/compliance/comply.d.ts +9 -3
- package/dist/lib/testing/compliance/comply.js +158 -3
- package/dist/lib/testing/compliance/comply.mjs +159 -4
- package/dist/lib/testing/compliance/storyboard-tracks.js +7 -5
- package/dist/lib/testing/compliance/storyboard-tracks.mjs +7 -5
- package/dist/lib/testing/compliance/summary.js +10 -1
- package/dist/lib/testing/compliance/summary.mjs +10 -1
- package/dist/lib/testing/index.d.mts +1 -1
- package/dist/lib/testing/index.d.ts +1 -1
- package/dist/lib/testing/index.js +2 -0
- package/dist/lib/testing/index.mjs +3 -1
- package/dist/lib/testing/storyboard/agent-routing.d.mts +12 -43
- package/dist/lib/testing/storyboard/agent-routing.d.ts +12 -43
- package/dist/lib/testing/storyboard/agent-routing.js +75 -13
- package/dist/lib/testing/storyboard/agent-routing.mjs +70 -12
- package/dist/lib/testing/storyboard/index.d.mts +1 -0
- package/dist/lib/testing/storyboard/index.d.ts +1 -0
- package/dist/lib/testing/storyboard/index.js +3 -0
- package/dist/lib/testing/storyboard/index.mjs +2 -0
- package/dist/lib/testing/storyboard/junit.d.mts +1 -1
- package/dist/lib/testing/storyboard/junit.d.ts +1 -1
- package/dist/lib/testing/storyboard/junit.js +21 -2
- package/dist/lib/testing/storyboard/junit.mjs +21 -2
- package/dist/lib/testing/storyboard/probes.d.mts +130 -0
- package/dist/lib/testing/storyboard/probes.d.ts +130 -0
- package/dist/lib/testing/storyboard/probes.js +682 -10
- package/dist/lib/testing/storyboard/probes.mjs +683 -3
- package/dist/lib/testing/storyboard/request-signing/builder.d.mts +16 -5
- package/dist/lib/testing/storyboard/request-signing/builder.d.ts +16 -5
- package/dist/lib/testing/storyboard/request-signing/grader.d.mts +44 -1
- package/dist/lib/testing/storyboard/request-signing/grader.d.ts +44 -1
- package/dist/lib/testing/storyboard/request-signing/grader.js +46 -22
- package/dist/lib/testing/storyboard/request-signing/grader.mjs +43 -21
- package/dist/lib/testing/storyboard/request-signing/probe-dispatch.d.mts +86 -11
- package/dist/lib/testing/storyboard/request-signing/probe-dispatch.d.ts +86 -11
- package/dist/lib/testing/storyboard/request-signing/probe-dispatch.js +119 -25
- package/dist/lib/testing/storyboard/request-signing/probe-dispatch.mjs +117 -26
- package/dist/lib/testing/storyboard/request-signing/synthesize.js +22 -2
- package/dist/lib/testing/storyboard/request-signing/synthesize.mjs +22 -2
- package/dist/lib/testing/storyboard/runner.d.mts +103 -0
- package/dist/lib/testing/storyboard/runner.d.ts +103 -0
- package/dist/lib/testing/storyboard/runner.js +1090 -268
- package/dist/lib/testing/storyboard/runner.mjs +1096 -261
- package/dist/lib/testing/storyboard/seeding.d.mts +4 -1
- package/dist/lib/testing/storyboard/seeding.d.ts +4 -1
- package/dist/lib/testing/storyboard/seeding.js +55 -24
- package/dist/lib/testing/storyboard/seeding.mjs +55 -24
- package/dist/lib/testing/storyboard/test-kit.d.mts +37 -3
- package/dist/lib/testing/storyboard/test-kit.d.ts +37 -3
- package/dist/lib/testing/storyboard/test-kit.js +8 -2
- package/dist/lib/testing/storyboard/test-kit.mjs +7 -2
- package/dist/lib/testing/storyboard/types.d.mts +132 -10
- package/dist/lib/testing/storyboard/types.d.ts +132 -10
- package/dist/lib/testing/storyboard/types.js +17 -0
- package/dist/lib/testing/storyboard/types.mjs +16 -0
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/testing/storyboard/validations.js +16 -0
- package/dist/lib/testing/storyboard/validations.mjs +16 -0
- package/dist/lib/testing/test-controller.d.mts +1 -1
- package/dist/lib/testing/test-controller.d.ts +1 -1
- package/dist/lib/types/buy-products.d.ts +71 -6
- package/dist/lib/types/control-media-buy.d.ts +25 -11
- package/dist/lib/types/core.generated.d.mts +69 -10
- package/dist/lib/types/core.generated.d.ts +69 -10
- package/dist/lib/types/create-media-buy.d.ts +71 -6
- package/dist/lib/types/forward-compat-error-codes.d.mts +7 -6
- package/dist/lib/types/forward-compat-error-codes.d.ts +7 -6
- package/dist/lib/types/index.d.mts +2 -2
- package/dist/lib/types/index.d.ts +2 -2
- package/dist/lib/types/schemas.generated.d.ts +8040 -8116
- package/dist/lib/types/schemas.generated.js +1074 -309
- package/dist/lib/types/schemas.generated.mjs +1068 -309
- package/dist/lib/types/tools.generated.d.mts +65 -6
- package/dist/lib/types/tools.generated.d.ts +65 -6
- package/dist/lib/types/update-media-buy.d.ts +71 -6
- package/dist/lib/utils/redact-secrets.d.mts +1 -1
- package/dist/lib/utils/redact-secrets.d.ts +1 -1
- package/dist/lib/utils/redact-secrets.js +1 -1
- package/dist/lib/utils/redact-secrets.mjs +1 -1
- package/dist/lib/v2/projection/cache-versions.d.mts +0 -1
- package/dist/lib/v2/projection/cache-versions.d.ts +0 -1
- package/dist/lib/v2/projection/cache-versions.js +1 -15
- package/dist/lib/v2/projection/cache-versions.mjs +1 -14
- package/dist/lib/v2/projection/canonical-properties.js +2 -2
- package/dist/lib/v2/projection/canonical-properties.mjs +3 -3
- package/dist/lib/v2/projection/registry.d.mts +1 -1
- package/dist/lib/v2/projection/registry.d.ts +1 -1
- package/dist/lib/v2/projection/registry.js +2 -2
- package/dist/lib/v2/projection/registry.mjs +3 -3
- package/dist/lib/validation/schema-loader.d.mts +9 -1
- package/dist/lib/validation/schema-loader.d.ts +9 -1
- package/dist/lib/validation/schema-loader.js +65 -8
- package/dist/lib/validation/schema-loader.mjs +64 -8
- package/dist/lib/version.d.mts +5 -5
- package/dist/lib/version.d.ts +5 -5
- package/dist/lib/version.js +3 -8
- package/dist/lib/version.mjs +3 -8
- package/dist/lib/wholesale-feed-sync/index.d.mts +1 -0
- package/dist/lib/wholesale-feed-sync/index.d.ts +1 -0
- package/dist/lib/wholesale-feed-sync/protocol-types.d.mts +42 -0
- package/dist/lib/wholesale-feed-sync/protocol-types.d.ts +42 -0
- package/dist/lib/wholesale-feed-sync/protocol-types.js +16 -0
- package/dist/lib/wholesale-feed-sync/protocol-types.mjs +0 -0
- package/dist/lib/wholesale-feed-sync/sync.d.mts +6 -6
- package/dist/lib/wholesale-feed-sync/sync.d.ts +6 -6
- package/dist/lib/wholesale-feed-sync/sync.js +3 -1
- package/dist/lib/wholesale-feed-sync/sync.mjs +3 -1
- package/dist/lib/wholesale-feed-sync/types.d.mts +15 -14
- package/dist/lib/wholesale-feed-sync/types.d.ts +15 -14
- package/dist/lib/wholesale-feed-sync/webhook-notification.d.mts +7 -5
- package/dist/lib/wholesale-feed-sync/webhook-notification.d.ts +7 -5
- package/dist/lib/wholesale-feed-sync/webhook-notification.js +45 -0
- package/dist/lib/wholesale-feed-sync/webhook-notification.mjs +44 -0
- package/docs/CLI.md +1 -1
- package/docs/TYPE-SUMMARY.md +118 -4
- package/docs/guides/ASYNC-API-REFERENCE.md +62 -1
- package/docs/guides/ASYNC-DEVELOPER-GUIDE.md +25 -0
- package/docs/guides/ASYNC-DOCUMENTATION-INDEX.md +3 -0
- package/docs/guides/BUYER-QUICKSTART-3.2.md +5 -0
- package/docs/guides/DURABLE-BUYER-WRITES.md +337 -0
- package/docs/guides/EXISTING-PLATFORM.md +80 -1
- package/docs/guides/MEDIA-BUY-3.2-COMPATIBILITY.md +57 -0
- package/docs/guides/MEDIA-BUY-ACTION-ASSESSMENT.md +300 -0
- package/docs/guides/REPORTING-LEDGER.md +654 -3
- package/docs/guides/REPORTING-RECONCILIATION.md +50 -0
- package/docs/guides/REPORTING-SOURCE-EXECUTOR.md +63 -1
- package/docs/guides/SELLER-QUICKSTART-3.2.md +2 -0
- package/docs/guides/VALIDATE-YOUR-AGENT.md +35 -0
- package/docs/guides/idempotency-crash-recovery.md +4 -0
- package/docs/llms.txt +4 -2
- package/docs/migration-14.x-rc-worksheet.md +60 -5
- package/docs/migration-7.9-to-7.10.md +7 -5
- package/examples/README.md +17 -0
- package/examples/durable-buyer-writes/caller.ts +745 -0
- package/examples/durable-buyer-writes/worker.ts +240 -0
- package/examples/reliable-reporting-service/README.md +100 -0
- package/examples/seller-3.2-starter.ts +7 -8
- package/examples/targeting-input-existing-platform.ts +153 -0
- package/package.json +41 -29
- package/skills/build-seller-agent/SKILL.md +2 -0
- package/skills/build-seller-agent/specialisms/signed-requests.md +11 -1
- package/skills/cross-cutting.md +28 -11
- package/compliance/cache/3.1.0-beta.7/domains/brand/index.yaml +0 -160
- package/compliance/cache/3.1.0-beta.7/domains/brand/scenarios/distributed_brand_resolution.yaml +0 -415
- package/compliance/cache/3.1.0-beta.7/domains/brand/scenarios/single_side_trust_extension.yaml +0 -454
- package/compliance/cache/3.1.0-beta.7/domains/creative/index.yaml +0 -339
- package/compliance/cache/3.1.0-beta.7/domains/creative/scenarios/billing_out_of_band.yaml +0 -153
- package/compliance/cache/3.1.0-beta.7/domains/creative/scenarios/creative_lifecycle_webhooks.yaml +0 -389
- package/compliance/cache/3.1.0-beta.7/domains/creative/scenarios/native_in_feed.yaml +0 -543
- package/compliance/cache/3.1.0-beta.7/domains/governance/index.yaml +0 -682
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/index.yaml +0 -781
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/audience_buy_flow.yaml +0 -380
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/available_actions.yaml +0 -565
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/billing_finality_delivery.yaml +0 -354
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/canonical_formats.yaml +0 -711
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/clicks_buy_flow.yaml +0 -264
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/completed_views_buy_flow.yaml +0 -344
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/create_media_buy_async.yaml +0 -234
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/creative_fate_after_cancellation.yaml +0 -419
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/creative_reception.yaml +0 -247
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/delivery_reporting.yaml +0 -357
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/dependency_impairment.yaml +0 -633
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/dependency_impairment_cardinality.yaml +0 -800
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/event_dedup_flow.yaml +0 -399
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/frequency_cap_enforcement.yaml +0 -309
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/governance_approved.yaml +0 -214
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/governance_conditions.yaml +0 -199
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/governance_denied.yaml +0 -204
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/governance_denied_recovery.yaml +0 -252
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/invalid_transitions.yaml +0 -289
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/inventory_list_no_match.yaml +0 -148
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/inventory_list_targeting.yaml +0 -276
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/measurement_accountability.yaml +0 -244
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/measurement_terms_rejected.yaml +0 -203
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/pending_creatives_to_start.yaml +0 -274
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/per_creative_conversion_attribution.yaml +0 -500
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/performance_buy_flow.yaml +0 -428
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/performance_buy_flow_roas.yaml +0 -470
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/product_signal_targeting.yaml +0 -373
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/proposal_finalize.yaml +0 -399
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/proposal_finalize_asap_timing.yaml +0 -264
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/proposal_not_found_errors.yaml +0 -257
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/provenance_audit_observation.yaml +0 -333
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/provenance_enforcement.yaml +0 -517
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/provenance_truth_of_claim.yaml +0 -294
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/reach_buy_flow.yaml +0 -823
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/refine_finalize_exclusivity.yaml +0 -360
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/refine_products.yaml +0 -148
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/vendor_metric_accountability.yaml +0 -293
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/vendor_metric_catalog_precondition.yaml +0 -307
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/scenarios/vendor_metric_optimization_flow.yaml +0 -576
- package/compliance/cache/3.1.0-beta.7/domains/media-buy/state-machine.yaml +0 -442
- package/compliance/cache/3.1.0-beta.7/domains/signals/index.yaml +0 -266
- package/compliance/cache/3.1.0-beta.7/domains/sponsored-intelligence/index.yaml +0 -256
- package/compliance/cache/3.1.0-beta.7/index.json +0 -356
- package/compliance/cache/3.1.0-beta.7/protocols/brand/index.yaml +0 -160
- package/compliance/cache/3.1.0-beta.7/protocols/brand/scenarios/distributed_brand_resolution.yaml +0 -415
- package/compliance/cache/3.1.0-beta.7/protocols/brand/scenarios/single_side_trust_extension.yaml +0 -454
- package/compliance/cache/3.1.0-beta.7/protocols/creative/index.yaml +0 -339
- package/compliance/cache/3.1.0-beta.7/protocols/creative/scenarios/billing_out_of_band.yaml +0 -153
- package/compliance/cache/3.1.0-beta.7/protocols/creative/scenarios/creative_lifecycle_webhooks.yaml +0 -389
- package/compliance/cache/3.1.0-beta.7/protocols/creative/scenarios/native_in_feed.yaml +0 -543
- package/compliance/cache/3.1.0-beta.7/protocols/governance/index.yaml +0 -682
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/index.yaml +0 -781
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/audience_buy_flow.yaml +0 -380
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/available_actions.yaml +0 -565
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/billing_finality_delivery.yaml +0 -354
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/canonical_formats.yaml +0 -711
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/clicks_buy_flow.yaml +0 -264
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/completed_views_buy_flow.yaml +0 -344
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/create_media_buy_async.yaml +0 -234
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/creative_fate_after_cancellation.yaml +0 -419
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/creative_reception.yaml +0 -247
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/delivery_reporting.yaml +0 -357
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/dependency_impairment.yaml +0 -633
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/dependency_impairment_cardinality.yaml +0 -800
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/event_dedup_flow.yaml +0 -399
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/frequency_cap_enforcement.yaml +0 -309
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/governance_approved.yaml +0 -214
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/governance_conditions.yaml +0 -199
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/governance_denied.yaml +0 -204
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/governance_denied_recovery.yaml +0 -252
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/invalid_transitions.yaml +0 -289
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/inventory_list_no_match.yaml +0 -148
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/inventory_list_targeting.yaml +0 -276
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/measurement_accountability.yaml +0 -244
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/measurement_terms_rejected.yaml +0 -203
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/pending_creatives_to_start.yaml +0 -274
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/per_creative_conversion_attribution.yaml +0 -500
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/performance_buy_flow.yaml +0 -428
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/performance_buy_flow_roas.yaml +0 -470
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/product_signal_targeting.yaml +0 -373
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/proposal_finalize.yaml +0 -399
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/proposal_finalize_asap_timing.yaml +0 -264
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/proposal_not_found_errors.yaml +0 -257
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/provenance_audit_observation.yaml +0 -333
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/provenance_enforcement.yaml +0 -517
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/provenance_truth_of_claim.yaml +0 -294
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/reach_buy_flow.yaml +0 -823
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/refine_finalize_exclusivity.yaml +0 -360
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/refine_products.yaml +0 -148
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/vendor_metric_accountability.yaml +0 -293
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/vendor_metric_catalog_precondition.yaml +0 -307
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/scenarios/vendor_metric_optimization_flow.yaml +0 -576
- package/compliance/cache/3.1.0-beta.7/protocols/media-buy/state-machine.yaml +0 -442
- package/compliance/cache/3.1.0-beta.7/protocols/signals/index.yaml +0 -266
- package/compliance/cache/3.1.0-beta.7/protocols/sponsored-intelligence/index.yaml +0 -256
- package/compliance/cache/3.1.0-beta.7/specialisms/audience-sync/index.yaml +0 -313
- package/compliance/cache/3.1.0-beta.7/specialisms/brand-rights/index.yaml +0 -350
- package/compliance/cache/3.1.0-beta.7/specialisms/brand-rights/scenarios/governance_denied.yaml +0 -226
- package/compliance/cache/3.1.0-beta.7/specialisms/collection-lists/index.yaml +0 -359
- package/compliance/cache/3.1.0-beta.7/specialisms/content-standards/index.yaml +0 -572
- package/compliance/cache/3.1.0-beta.7/specialisms/creative-ad-server/index.yaml +0 -409
- package/compliance/cache/3.1.0-beta.7/specialisms/creative-generative/generative-seller.yaml +0 -807
- package/compliance/cache/3.1.0-beta.7/specialisms/creative-generative/index.yaml +0 -758
- package/compliance/cache/3.1.0-beta.7/specialisms/creative-template/index.yaml +0 -510
- package/compliance/cache/3.1.0-beta.7/specialisms/governance-aware-seller/index.yaml +0 -143
- package/compliance/cache/3.1.0-beta.7/specialisms/governance-aware-seller/scenarios/governance_multi_agent_rejected.yaml +0 -117
- package/compliance/cache/3.1.0-beta.7/specialisms/governance-delivery-monitor/index.yaml +0 -441
- package/compliance/cache/3.1.0-beta.7/specialisms/governance-spend-authority/denied.yaml +0 -221
- package/compliance/cache/3.1.0-beta.7/specialisms/governance-spend-authority/index.yaml +0 -330
- package/compliance/cache/3.1.0-beta.7/specialisms/property-lists/index.yaml +0 -482
- package/compliance/cache/3.1.0-beta.7/specialisms/sales-broadcast-tv/index.yaml +0 -738
- package/compliance/cache/3.1.0-beta.7/specialisms/sales-catalog-driven/index.yaml +0 -840
- package/compliance/cache/3.1.0-beta.7/specialisms/sales-guaranteed/index.yaml +0 -601
- package/compliance/cache/3.1.0-beta.7/specialisms/sales-non-guaranteed/index.yaml +0 -546
- package/compliance/cache/3.1.0-beta.7/specialisms/sales-proposal-mode/index.yaml +0 -586
- package/compliance/cache/3.1.0-beta.7/specialisms/sales-social/index.yaml +0 -919
- package/compliance/cache/3.1.0-beta.7/specialisms/signal-marketplace/index.yaml +0 -424
- package/compliance/cache/3.1.0-beta.7/specialisms/signal-marketplace/scenarios/governance_denied.yaml +0 -211
- package/compliance/cache/3.1.0-beta.7/specialisms/signal-owned/index.yaml +0 -317
- package/compliance/cache/3.1.0-beta.7/specialisms/sponsored-intelligence/index.yaml +0 -59
- package/compliance/cache/3.1.0-beta.7/test-kits/acme-outdoor-live.yaml +0 -78
- package/compliance/cache/3.1.0-beta.7/test-kits/acme-outdoor.yaml +0 -223
- package/compliance/cache/3.1.0-beta.7/test-kits/billing-gate-runner.yaml +0 -115
- package/compliance/cache/3.1.0-beta.7/test-kits/bistro-oranje.yaml +0 -126
- package/compliance/cache/3.1.0-beta.7/test-kits/distributed-brand-runner.yaml +0 -281
- package/compliance/cache/3.1.0-beta.7/test-kits/nova-motors.yaml +0 -262
- package/compliance/cache/3.1.0-beta.7/test-kits/osei-natural.yaml +0 -126
- package/compliance/cache/3.1.0-beta.7/test-kits/parallel-dispatch-runner.yaml +0 -196
- package/compliance/cache/3.1.0-beta.7/test-kits/rate-limit-trip-runner.yaml +0 -172
- package/compliance/cache/3.1.0-beta.7/test-kits/signed-requests-runner.yaml +0 -155
- package/compliance/cache/3.1.0-beta.7/test-kits/single-side-trust-runner.yaml +0 -294
- package/compliance/cache/3.1.0-beta.7/test-kits/substitution-observer-runner.yaml +0 -688
- package/compliance/cache/3.1.0-beta.7/test-kits/summit-foods.yaml +0 -125
- package/compliance/cache/3.1.0-beta.7/test-kits/webhook-receiver-runner.yaml +0 -265
- package/compliance/cache/3.1.0-beta.7/test-vectors/plan-hash/001-minimal-plan.json +0 -43
- package/compliance/cache/3.1.0-beta.7/test-vectors/plan-hash/002-full-plan.json +0 -217
- package/compliance/cache/3.1.0-beta.7/test-vectors/plan-hash/003-bookkeeping-stripped.json +0 -60
- package/compliance/cache/3.1.0-beta.7/test-vectors/plan-hash/004a-human-review-omitted.json +0 -43
- package/compliance/cache/3.1.0-beta.7/test-vectors/plan-hash/004b-human-review-explicit-null.json +0 -49
- package/compliance/cache/3.1.0-beta.7/test-vectors/plan-hash/005a-policy-categories-order-1.json +0 -53
- package/compliance/cache/3.1.0-beta.7/test-vectors/plan-hash/005b-policy-categories-order-2.json +0 -57
- package/compliance/cache/3.1.0-beta.7/test-vectors/plan-hash/006a-ext-trace-v1.json +0 -49
- package/compliance/cache/3.1.0-beta.7/test-vectors/plan-hash/006b-ext-trace-v2.json +0 -53
- package/compliance/cache/3.1.0-beta.7/test-vectors/plan-hash/007-unicode-objectives.json +0 -43
- package/compliance/cache/3.1.0-beta.7/test-vectors/plan-hash/008-numeric-canonicalization.json +0 -65
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/README.md +0 -220
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/canonicalization.json +0 -241
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/keys.json +0 -60
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/001-no-signature-header.json +0 -24
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/002-wrong-tag.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/003-expired-signature.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/004-window-too-long.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/005-alg-not-allowed.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/006-missing-covered-component.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/007-missing-content-digest.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/008-unknown-keyid.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/009-key-ops-missing-verify.json +0 -27
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/010-content-digest-mismatch.json +0 -33
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/011-malformed-header.json +0 -27
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/012-missing-expires-param.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/013-expires-le-created.json +0 -27
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/014-missing-nonce-param.json +0 -27
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/015-signature-invalid.json +0 -28
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/016-replayed-nonce.json +0 -35
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/017-key-revoked.json +0 -38
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/018-digest-covered-when-forbidden.json +0 -28
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/019-signature-without-signature-input.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/020-rate-abuse.json +0 -34
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/021-duplicate-signature-input-label.json +0 -31
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/022-multi-valued-content-type.json +0 -31
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/023-multi-valued-content-digest.json +0 -32
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/024-unquoted-string-param.json +0 -31
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/025-jwk-alg-crv-mismatch.json +0 -43
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/026-non-ascii-host.json +0 -31
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/027-webhook-registration-authentication-unsigned.json +0 -25
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/negative/028-unsigned-protocol-method-required.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/positive/001-basic-post.json +0 -30
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/positive/002-post-with-content-digest.json +0 -31
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/positive/003-es256-post.json +0 -30
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/positive/004-multiple-signature-labels.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/positive/005-default-port-stripped.json +0 -30
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/positive/006-dot-segment-path.json +0 -30
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/positive/007-query-byte-preserved.json +0 -30
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/positive/008-percent-encoded-path.json +0 -30
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/positive/009-percent-encoded-unreserved-decoded.json +0 -30
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/positive/010-percent-encoded-slash-preserved.json +0 -30
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/positive/011-ipv6-authority.json +0 -30
- package/compliance/cache/3.1.0-beta.7/test-vectors/request-signing/positive/012-ipv6-authority-default-port-stripped.json +0 -30
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/README.md +0 -211
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/keys.json +0 -61
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/001-wrong-tag.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/002-expired-signature.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/003-window-too-long.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/004-alg-not-allowed.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/005-missing-authority-component.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/006-missing-content-digest.json +0 -25
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/007-unknown-keyid.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/008-wrong-adcp-use.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/009-content-digest-mismatch.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/010-malformed-signature-input.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/011-signature-without-input.json +0 -25
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/012-missing-expires-param.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/013-expires-le-created.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/014-missing-nonce-param.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/015-signature-invalid.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/016-replayed-nonce.json +0 -37
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/017-key-revoked.json +0 -32
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/018-rate-abuse.json +0 -33
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/019-revocation-stale.json +0 -32
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/020-key-ops-missing-verify.json +0 -41
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/negative/021-base64-alphabet-mixing.json +0 -26
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/positive/001-basic-post.json +0 -24
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/positive/002-es256-post.json +0 -24
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/positive/003-multiple-signature-labels.json +0 -24
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/positive/004-default-port-stripped.json +0 -24
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/positive/005-percent-encoded-path.json +0 -24
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/positive/006-query-byte-preserved.json +0 -24
- package/compliance/cache/3.1.0-beta.7/test-vectors/webhook-signing/positive/007-body-without-idempotency-key.json +0 -25
- package/compliance/cache/3.1.0-beta.7/universal/billing-gate-dispatch.yaml +0 -450
- package/compliance/cache/3.1.0-beta.7/universal/canonical-format-validate-input.yaml +0 -640
- package/compliance/cache/3.1.0-beta.7/universal/capability-discovery.yaml +0 -125
- package/compliance/cache/3.1.0-beta.7/universal/collection-lists-pagination-integrity.yaml +0 -306
- package/compliance/cache/3.1.0-beta.7/universal/comply-controller-mode-gate.yaml +0 -141
- package/compliance/cache/3.1.0-beta.7/universal/content-standards-pagination-integrity.yaml +0 -326
- package/compliance/cache/3.1.0-beta.7/universal/deterministic-testing.yaml +0 -1430
- package/compliance/cache/3.1.0-beta.7/universal/error-compliance-signals.yaml +0 -377
- package/compliance/cache/3.1.0-beta.7/universal/error-compliance.yaml +0 -528
- package/compliance/cache/3.1.0-beta.7/universal/fictional-entities.yaml +0 -307
- package/compliance/cache/3.1.0-beta.7/universal/get-media-buys-pagination-integrity.yaml +0 -160
- package/compliance/cache/3.1.0-beta.7/universal/get-signals-pagination-integrity.yaml +0 -211
- package/compliance/cache/3.1.0-beta.7/universal/idempotency.yaml +0 -861
- package/compliance/cache/3.1.0-beta.7/universal/notification-config-event-scope.yaml +0 -119
- package/compliance/cache/3.1.0-beta.7/universal/notification-config-lifecycle.yaml +0 -337
- package/compliance/cache/3.1.0-beta.7/universal/notification-config-rejections.yaml +0 -107
- package/compliance/cache/3.1.0-beta.7/universal/pagination-integrity-creative-formats.yaml +0 -265
- package/compliance/cache/3.1.0-beta.7/universal/pagination-integrity-list-accounts.yaml +0 -245
- package/compliance/cache/3.1.0-beta.7/universal/pagination-integrity.yaml +0 -263
- package/compliance/cache/3.1.0-beta.7/universal/property-lists-pagination-integrity.yaml +0 -307
- package/compliance/cache/3.1.0-beta.7/universal/read-tool-idempotency.yaml +0 -405
- package/compliance/cache/3.1.0-beta.7/universal/runner-output-contract.yaml +0 -1266
- package/compliance/cache/3.1.0-beta.7/universal/schema-validation-signals.yaml +0 -181
- package/compliance/cache/3.1.0-beta.7/universal/schema-validation.yaml +0 -548
- package/compliance/cache/3.1.0-beta.7/universal/security.yaml +0 -539
- package/compliance/cache/3.1.0-beta.7/universal/signed-requests.yaml +0 -217
- package/compliance/cache/3.1.0-beta.7/universal/stale-response-advisory.yaml +0 -295
- package/compliance/cache/3.1.0-beta.7/universal/storyboard-schema.yaml +0 -2136
- package/compliance/cache/3.1.0-beta.7/universal/v3-envelope-integrity.yaml +0 -117
- package/compliance/cache/3.1.0-beta.7/universal/version-negotiation.yaml +0 -130
- package/compliance/cache/3.1.0-beta.7/universal/webhook-emission.yaml +0 -411
- package/compliance/cache/3.1.0-beta.7/universal/wholesale-feed-bulk-webhooks.yaml +0 -82
- package/compliance/cache/3.1.0-beta.7/universal/wholesale-feed-product-webhooks.yaml +0 -83
- package/compliance/cache/3.1.0-beta.7/universal/wholesale-feed-products.yaml +0 -151
- package/compliance/cache/3.1.0-beta.7/universal/wholesale-feed-signal-webhooks.yaml +0 -83
- package/compliance/cache/3.1.0-beta.7/universal/wholesale-feed-signals.yaml +0 -149
- package/dist/lib/types/v3-1-beta/index.d.mts +0 -1
- package/dist/lib/types/v3-1-beta/index.d.ts +0 -1
- package/dist/lib/types/v3-1-beta/index.mjs +0 -1
- package/dist/lib/types/v3-1-beta/tools.generated.d.mts +0 -26788
- package/dist/lib/types/v3-1-beta/tools.generated.d.ts +0 -26788
- /package/dist/lib/{types/v3-1-beta/tools.generated.mjs → media-buy/action-types.mjs} +0 -0
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
import { buildReportingSourceManifestV1 } from "./builder.mjs";
|
|
3
4
|
import { validateReportingSourceRequestAgainstCapabilitiesV1 } from "./conformance.mjs";
|
|
4
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
canonicalJsonV1,
|
|
7
|
+
ReportingEvidenceReasonV1Schema,
|
|
8
|
+
ReportingExternalIdV1Schema,
|
|
9
|
+
REPORTING_SOURCE_CONTRACT_VERSION_V1,
|
|
10
|
+
SOURCE_BATCH_MANIFEST_MAX_METRIC_AVAILABILITY_V1,
|
|
11
|
+
SourceBatchContractError
|
|
12
|
+
} from "./manifest.mjs";
|
|
5
13
|
import {
|
|
6
14
|
completedReportingSourceResponseV1,
|
|
7
15
|
reportingIsoDurationMillisecondsV1,
|
|
16
|
+
ReportingMetricOrDimensionNameV1Schema,
|
|
8
17
|
reportingSourceCapabilitiesV1,
|
|
9
18
|
ReportingSourceErrorV1Schema,
|
|
10
19
|
ReportingSourceOfferingV1Schema,
|
|
11
20
|
ReportingSourceSliceRequestV1Schema
|
|
12
21
|
} from "./source.mjs";
|
|
22
|
+
const INLINE_REPORTING_AVAILABILITY_EVIDENCE_VERSION_V1 = "1.0";
|
|
13
23
|
class ReportingSourceNotReadyError extends Error {
|
|
14
24
|
constructor(message = "Reporting data is not ready") {
|
|
15
25
|
super(message);
|
|
@@ -32,7 +42,87 @@ const INLINE_MAX_OBJECT_BYTES_V1 = 64 * 1024 * 1024;
|
|
|
32
42
|
const INLINE_MAX_TOTAL_OBJECT_BYTES_V1 = 256 * 1024 * 1024;
|
|
33
43
|
const INLINE_MAX_SCOPE_OBJECT_BYTES_V1 = 32 * 1024 * 1024;
|
|
34
44
|
const INLINE_MAX_ROWS_V1 = 1e5;
|
|
35
|
-
|
|
45
|
+
const INLINE_SHIPPED_CAPACITIES_V1 = {
|
|
46
|
+
object: INLINE_MAX_OBJECT_BYTES_V1,
|
|
47
|
+
total: INLINE_MAX_TOTAL_OBJECT_BYTES_V1,
|
|
48
|
+
scope: INLINE_MAX_SCOPE_OBJECT_BYTES_V1,
|
|
49
|
+
executions: INLINE_MAX_EXECUTIONS_V1,
|
|
50
|
+
scopeExecutions: INLINE_MAX_EXECUTIONS_PER_SCOPE_V1
|
|
51
|
+
};
|
|
52
|
+
function tightenInlineStagingCapacities(override) {
|
|
53
|
+
const tighten = (shipped, value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? Math.min(shipped, value) : shipped;
|
|
54
|
+
return {
|
|
55
|
+
object: tighten(INLINE_MAX_OBJECT_BYTES_V1, override.object),
|
|
56
|
+
total: tighten(INLINE_MAX_TOTAL_OBJECT_BYTES_V1, override.total),
|
|
57
|
+
scope: tighten(INLINE_MAX_SCOPE_OBJECT_BYTES_V1, override.scope),
|
|
58
|
+
executions: tighten(INLINE_MAX_EXECUTIONS_V1, override.executions),
|
|
59
|
+
scopeExecutions: tighten(INLINE_MAX_EXECUTIONS_PER_SCOPE_V1, override.scopeExecutions)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const INLINE_MAX_VALIDATION_WORK_UNITS_V1 = 5e6;
|
|
63
|
+
const INLINE_MAX_VALIDATION_SCAN_BYTES_V1 = INLINE_MAX_OBJECT_BYTES_V1;
|
|
64
|
+
const INLINE_MAX_VALIDATION_RETAINED_BYTES_V1 = INLINE_MAX_OBJECT_BYTES_V1;
|
|
65
|
+
const INLINE_RETAINED_BYTES_PER_ROW_V1 = 48;
|
|
66
|
+
const INLINE_RETAINED_BYTES_PER_CLAIM_V1 = 9;
|
|
67
|
+
const INLINE_MAX_STATUS_CHARS_V1 = 32;
|
|
68
|
+
const INLINE_NO_CLAIMS_OFFSET_V1 = -1;
|
|
69
|
+
const INLINE_MAX_EVIDENCE_OBJECT_KEYS_V1 = 16;
|
|
70
|
+
const INLINE_MAX_EVIDENCE_FIELD_CHARS_V1 = 1024;
|
|
71
|
+
const INLINE_EVIDENCE_ENVELOPE_KEYS_V1 = ["version", "cells"];
|
|
72
|
+
const INLINE_EVIDENCE_CELL_KEYS_V1 = ["constituent_id", "metric", "status", "reason", "data_through"];
|
|
73
|
+
const INLINE_UNAVAILABLE_ROW_STATUSES_V1 = [
|
|
74
|
+
"failed",
|
|
75
|
+
"reporting_delayed",
|
|
76
|
+
"not_ready",
|
|
77
|
+
"pending",
|
|
78
|
+
"unavailable",
|
|
79
|
+
"error"
|
|
80
|
+
];
|
|
81
|
+
const INLINE_UNAVAILABLE_CELL_STATUSES_V1 = ["unsupported", "delayed", "missing"];
|
|
82
|
+
const INLINE_MAX_PROTOTYPE_CHAIN_DEPTH_V1 = 64;
|
|
83
|
+
const INLINE_MAX_DECIMAL_EXPONENT_V1 = 400;
|
|
84
|
+
const InlineReportingMetricEvidenceV1Schema = z.discriminatedUnion("status", [
|
|
85
|
+
z.strictObject({
|
|
86
|
+
constituent_id: ReportingExternalIdV1Schema,
|
|
87
|
+
metric: ReportingMetricOrDimensionNameV1Schema,
|
|
88
|
+
status: z.enum(["present", "explicit_zero"]),
|
|
89
|
+
data_through: z.string().trim().min(1).max(64),
|
|
90
|
+
reason: z.never().optional()
|
|
91
|
+
}),
|
|
92
|
+
z.strictObject({
|
|
93
|
+
constituent_id: ReportingExternalIdV1Schema,
|
|
94
|
+
metric: ReportingMetricOrDimensionNameV1Schema,
|
|
95
|
+
status: z.enum(["unsupported", "delayed", "partial", "stale", "missing"]),
|
|
96
|
+
reason: ReportingEvidenceReasonV1Schema,
|
|
97
|
+
data_through: z.string().trim().min(1).max(64).optional()
|
|
98
|
+
})
|
|
99
|
+
]);
|
|
100
|
+
const InlineReportingAvailabilityEvidenceV1Schema = z.strictObject({
|
|
101
|
+
version: z.literal(INLINE_REPORTING_AVAILABILITY_EVIDENCE_VERSION_V1),
|
|
102
|
+
cells: z.array(InlineReportingMetricEvidenceV1Schema).min(1).max(SOURCE_BATCH_MANIFEST_MAX_METRIC_AVAILABILITY_V1)
|
|
103
|
+
});
|
|
104
|
+
function createInlineReportingSourceExecutor(deliveryFetch, offeringInput, executorOptions = {}) {
|
|
105
|
+
return createInlineExecutorWithCapacities(
|
|
106
|
+
deliveryFetch,
|
|
107
|
+
offeringInput,
|
|
108
|
+
executorOptions,
|
|
109
|
+
INLINE_SHIPPED_CAPACITIES_V1
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
function createInlineReportingSourceExecutorForTestsV1(deliveryFetch, offeringInput, executorOptions, capacities, observer) {
|
|
113
|
+
return createInlineExecutorWithCapacities(
|
|
114
|
+
deliveryFetch,
|
|
115
|
+
offeringInput,
|
|
116
|
+
executorOptions,
|
|
117
|
+
tightenInlineStagingCapacities(capacities),
|
|
118
|
+
observer
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
function inlineStagingCapacitiesForTestsV1(capacities) {
|
|
122
|
+
return tightenInlineStagingCapacities(capacities);
|
|
123
|
+
}
|
|
124
|
+
function createInlineExecutorWithCapacities(deliveryFetch, offeringInput, executorOptions, capacities, observer) {
|
|
125
|
+
const evictSettled = executorOptions.replayRetention?.evictSettled === true;
|
|
36
126
|
const parsedOffering = ReportingSourceOfferingV1Schema.parse(offeringInput);
|
|
37
127
|
if (!parsedOffering.sourceExecution.manifestLevels.includes("basic")) {
|
|
38
128
|
throw new TypeError("Inline reporting requires a basic manifest offering");
|
|
@@ -125,17 +215,39 @@ function createInlineReportingSourceExecutor(deliveryFetch, offeringInput) {
|
|
|
125
215
|
if (existing.requestFingerprint !== requestFingerprint) {
|
|
126
216
|
return failure("INTEGRITY_FAILED", "terminal", "sourceExecutionKey was reused with a different request");
|
|
127
217
|
}
|
|
218
|
+
existing.reservation = void 0;
|
|
128
219
|
return awaitInlineExecution(existing, context.signal, request.deadline.deadlineAt);
|
|
129
220
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
return failure(
|
|
221
|
+
const scopeCount = [...executions.values()].filter((candidate) => candidate.scopeKey === scopeKey).length;
|
|
222
|
+
const exhaustedGlobally = executions.size >= capacities.executions;
|
|
223
|
+
const exhaustedForScope = scopeCount >= capacities.scopeExecutions;
|
|
224
|
+
if ((exhaustedGlobally || exhaustedForScope) && !evictSettled) {
|
|
225
|
+
return failure(
|
|
226
|
+
"QUOTA_EXHAUSTED",
|
|
227
|
+
"terminal",
|
|
228
|
+
`Inline reporting ${exhaustedGlobally ? "replay" : "scope replay"} capacity is exhausted; supply a durable executor or an explicit replayRetention policy for long-lived feeds`
|
|
229
|
+
);
|
|
135
230
|
}
|
|
136
231
|
if (activeExecutions >= INLINE_MAX_CONCURRENT_EXECUTIONS_V1) {
|
|
137
232
|
return failure("RATE_LIMITED", "retryable", "Inline reporting concurrency capacity is exhausted");
|
|
138
233
|
}
|
|
234
|
+
const reclaimer = evictSettled ? createAdmissionReclaimer(executions, storage) : void 0;
|
|
235
|
+
if (exhaustedGlobally && reclaimer?.plan(scopeKey, false) === void 0) {
|
|
236
|
+
reclaimer?.release();
|
|
237
|
+
return failure(
|
|
238
|
+
"QUOTA_EXHAUSTED",
|
|
239
|
+
"terminal",
|
|
240
|
+
"Inline reporting replay capacity is exhausted; supply a durable executor or an explicit replayRetention policy for long-lived feeds"
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
if (scopeCount - (reclaimer?.plannedInScope(scopeKey) ?? 0) >= capacities.scopeExecutions && reclaimer?.plan(scopeKey, true) === void 0) {
|
|
244
|
+
reclaimer?.release();
|
|
245
|
+
return failure(
|
|
246
|
+
"QUOTA_EXHAUSTED",
|
|
247
|
+
"terminal",
|
|
248
|
+
"Inline reporting scope replay capacity is exhausted; supply a durable executor or an explicit replayRetention policy for long-lived feeds"
|
|
249
|
+
);
|
|
250
|
+
}
|
|
139
251
|
activeExecutions += 1;
|
|
140
252
|
const controller = new AbortController();
|
|
141
253
|
const pending = Promise.resolve().then(
|
|
@@ -149,7 +261,10 @@ function createInlineReportingSourceExecutor(deliveryFetch, offeringInput) {
|
|
|
149
261
|
controller.signal,
|
|
150
262
|
storage,
|
|
151
263
|
key,
|
|
152
|
-
scopeKey
|
|
264
|
+
scopeKey,
|
|
265
|
+
capacities,
|
|
266
|
+
reclaimer,
|
|
267
|
+
observer
|
|
153
268
|
)
|
|
154
269
|
).then((result) => ({ requestFingerprint, result })).catch(() => ({
|
|
155
270
|
requestFingerprint,
|
|
@@ -157,6 +272,7 @@ function createInlineReportingSourceExecutor(deliveryFetch, offeringInput) {
|
|
|
157
272
|
})).finally(() => {
|
|
158
273
|
activeExecutions -= 1;
|
|
159
274
|
entry.pending = false;
|
|
275
|
+
reclaimer?.release();
|
|
160
276
|
});
|
|
161
277
|
const entry = {
|
|
162
278
|
scopeKey,
|
|
@@ -188,13 +304,17 @@ function createInlineReportingSourceExecutor(deliveryFetch, offeringInput) {
|
|
|
188
304
|
};
|
|
189
305
|
return executor;
|
|
190
306
|
}
|
|
191
|
-
async function executeAndSeal(deliveryFetch, offering, format, request, deliveryDates, deadlineAt, signal, storage, executionNamespace, scopeKey) {
|
|
307
|
+
async function executeAndSeal(deliveryFetch, offering, format, request, deliveryDates, deadlineAt, signal, storage, executionNamespace, scopeKey, capacities, reclaimer, observer) {
|
|
192
308
|
let fetched;
|
|
193
309
|
try {
|
|
194
310
|
fetched = await deliveryFetch(
|
|
195
311
|
{
|
|
196
312
|
account: structuredClone(request.account),
|
|
197
313
|
media_buy_ids: [...request.coverage.mediaBuyIds],
|
|
314
|
+
constituents: request.coverage.constituents.map((constituent) => ({
|
|
315
|
+
constituent_id: constituent.constituentId,
|
|
316
|
+
media_buy_id: constituent.mediaBuyId
|
|
317
|
+
})),
|
|
198
318
|
start_date: deliveryDates.start,
|
|
199
319
|
end_date: deliveryDates.end,
|
|
200
320
|
source_read_cutoff_at: request.period.sourceReadCutoffAt,
|
|
@@ -228,70 +348,209 @@ async function executeAndSeal(deliveryFetch, offering, format, request, delivery
|
|
|
228
348
|
if (fetched === null) {
|
|
229
349
|
return failure("NOT_READY", "retryable", "Reporting data is not ready");
|
|
230
350
|
}
|
|
231
|
-
const
|
|
351
|
+
const fetchedRecord = !isRows(fetched) ? fetched : void 0;
|
|
352
|
+
let rawStatus;
|
|
353
|
+
try {
|
|
354
|
+
rawStatus = fetchedRecord?.status;
|
|
355
|
+
} catch {
|
|
356
|
+
return failure("SOURCE_PERMANENT", "terminal", "Inline delivery fetch returned an unreadable response");
|
|
357
|
+
}
|
|
358
|
+
if (rawStatus !== void 0 && typeof rawStatus !== "string") {
|
|
359
|
+
return failure("SOURCE_PERMANENT", "terminal", "Inline delivery fetch reported an unreadable status");
|
|
360
|
+
}
|
|
361
|
+
const responseStatus = boundedLowerCaseStatus(rawStatus);
|
|
232
362
|
if (["failed", "error", "canceled", "cancelled", "rejected"].includes(responseStatus ?? "")) {
|
|
233
363
|
return failure("SOURCE_TRANSIENT", "retryable", "Inline delivery fetch reported failure");
|
|
234
364
|
}
|
|
235
365
|
if (responseStatus === "unavailable") {
|
|
236
366
|
return failure("PARTIAL_RESULT", "retryable", "Inline delivery fetch reported unavailable data");
|
|
237
367
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
368
|
+
const readResponseField = createResponseFieldReader(fetchedRecord);
|
|
369
|
+
const scalarFailure = (() => {
|
|
370
|
+
try {
|
|
371
|
+
if (!isRows(fetched) && (["working", "submitted", "input_required", "deferred", "reporting_delayed", "not_ready", "pending"].includes(
|
|
372
|
+
responseStatus ?? ""
|
|
373
|
+
) || request.publicationClass === "AUTHORITATIVE" && readResponseField("is_final") === false)) {
|
|
374
|
+
return failure("NOT_READY", "retryable", "Reporting data is not ready");
|
|
375
|
+
}
|
|
376
|
+
if (request.publicationClass === "AUTHORITATIVE" && (isRows(fetched) || readResponseField("is_final") !== true && !["final", "adjusted"].includes(asStringOrUndefined(readResponseField("notification_type")) ?? ""))) {
|
|
377
|
+
return failure("NOT_READY", "retryable", "Authoritative inline reporting requires source finality evidence");
|
|
378
|
+
}
|
|
379
|
+
if (!isRows(fetched) && (Boolean(readResponseField("partial_data")) || looseCount(readResponseField("unavailable_count")) > 0 || looseCount(lengthOfUnknown(readResponseField("errors"))) > 0)) {
|
|
380
|
+
return failure("PARTIAL_RESULT", "retryable", "Inline delivery fetch returned partial data");
|
|
381
|
+
}
|
|
382
|
+
const pagination = readResponseField("pagination");
|
|
383
|
+
if (!isRows(fetched) && fetchedRecord !== void 0 && pagination !== void 0) {
|
|
384
|
+
const paginationRecord = asRowRecord(pagination);
|
|
385
|
+
if (paginationRecord?.has_more !== false || Boolean(paginationRecord?.next_cursor)) {
|
|
386
|
+
return failure("PARTIAL_RESULT", "retryable", "Inline delivery fetch returned unfinished pagination");
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return void 0;
|
|
390
|
+
} catch {
|
|
391
|
+
return failure("SOURCE_PERMANENT", "terminal", "Inline delivery fetch returned an unreadable response");
|
|
392
|
+
}
|
|
393
|
+
})();
|
|
394
|
+
if (scalarFailure) return scalarFailure;
|
|
395
|
+
let reportingRowsInput;
|
|
396
|
+
let mediaBuyDeliveriesInput;
|
|
397
|
+
try {
|
|
398
|
+
reportingRowsInput = fetchedRecord ? fetchedRecord.reporting_rows : void 0;
|
|
399
|
+
mediaBuyDeliveriesInput = fetchedRecord ? fetchedRecord.media_buy_deliveries : void 0;
|
|
400
|
+
} catch {
|
|
401
|
+
return failure("SOURCE_PERMANENT", "terminal", "Inline delivery fetch returned an invalid row collection");
|
|
245
402
|
}
|
|
246
|
-
|
|
247
|
-
|
|
403
|
+
const availabilityEvidenceSlot = fetchedRecord ? resolveOwnDataSlot(fetchedRecord, "availability_evidence") : { kind: "absent" };
|
|
404
|
+
if (reportingRowsInput !== void 0 && !Array.isArray(reportingRowsInput) || mediaBuyDeliveriesInput !== void 0 && !Array.isArray(mediaBuyDeliveriesInput)) {
|
|
405
|
+
return failure("SOURCE_PERMANENT", "terminal", "Inline delivery fetch returned an invalid row collection");
|
|
248
406
|
}
|
|
249
|
-
|
|
250
|
-
|
|
407
|
+
const reportingRows = reportingRowsInput;
|
|
408
|
+
const mediaBuyDeliveries = mediaBuyDeliveriesInput;
|
|
409
|
+
const reportingRowsLength = boundedCollectionLength(reportingRows);
|
|
410
|
+
const mediaBuyDeliveriesLength = boundedCollectionLength(mediaBuyDeliveries);
|
|
411
|
+
const sourceDeclaredLength = isRows(fetched) ? boundedCollectionLength(fetched) : reportingRows !== void 0 ? reportingRowsLength : mediaBuyDeliveriesLength;
|
|
412
|
+
if (reportingRowsLength === void 0 || mediaBuyDeliveriesLength === void 0 || sourceDeclaredLength === void 0) {
|
|
413
|
+
return failure("SOURCE_PERMANENT", "terminal", "Inline delivery fetch returned an invalid row collection");
|
|
251
414
|
}
|
|
252
|
-
if (!isRows(fetched) &&
|
|
415
|
+
if (!isRows(fetched) && reportingRows === void 0 && mediaBuyDeliveries === void 0) {
|
|
253
416
|
return failure("SOURCE_PERMANENT", "terminal", "Inline delivery fetch omitted its row collection");
|
|
254
417
|
}
|
|
255
|
-
|
|
418
|
+
let responsePeriod;
|
|
419
|
+
let responseCurrency;
|
|
420
|
+
try {
|
|
421
|
+
const period = asRowRecord(readResponseField("reporting_period"));
|
|
422
|
+
const periodStart = period?.start;
|
|
423
|
+
const periodEnd = period?.end;
|
|
424
|
+
responsePeriod = {
|
|
425
|
+
present: period !== void 0 && periodStart !== void 0 && periodEnd !== void 0,
|
|
426
|
+
start: periodStart,
|
|
427
|
+
end: periodEnd
|
|
428
|
+
};
|
|
429
|
+
responseCurrency = readResponseField("currency");
|
|
430
|
+
} catch {
|
|
431
|
+
return failure("SOURCE_PERMANENT", "terminal", "Inline delivery fetch returned an unreadable response");
|
|
432
|
+
}
|
|
433
|
+
if (!isRows(fetched) && (!responsePeriod.present || !deliveryPeriodBoundaryMatches(responsePeriod.start, deliveryDates.start, request.period.start) || !deliveryPeriodBoundaryMatches(responsePeriod.end, deliveryDates.end, request.period.end))) {
|
|
256
434
|
return failure("PARTIAL_RESULT", "retryable", "Inline delivery fetch did not prove the requested half-open period");
|
|
257
435
|
}
|
|
258
|
-
if (!isRows(fetched) &&
|
|
436
|
+
if (!isRows(fetched) && responseCurrency !== void 0 && responseCurrency !== request.sourceSettings.currency) {
|
|
259
437
|
return failure(
|
|
260
438
|
"INTEGRITY_FAILED",
|
|
261
439
|
"terminal",
|
|
262
440
|
"Inline delivery currency does not match the frozen source settings"
|
|
263
441
|
);
|
|
264
442
|
}
|
|
265
|
-
if (!isRows(fetched) && (
|
|
443
|
+
if (!isRows(fetched) && (reportingRowsLength > INLINE_MAX_ROWS_V1 || mediaBuyDeliveriesLength > INLINE_MAX_ROWS_V1 || reportingRowsLength + mediaBuyDeliveriesLength > INLINE_MAX_ROWS_V1)) {
|
|
266
444
|
return failure("QUOTA_EXHAUSTED", "terminal", "Inline delivery fetch exceeded the row limit");
|
|
267
445
|
}
|
|
268
|
-
if (!isRows(fetched) &&
|
|
446
|
+
if (!isRows(fetched) && reportingRows !== void 0 && mediaBuyDeliveries !== void 0 && reportingRowsLength === 0 !== (mediaBuyDeliveriesLength === 0)) {
|
|
269
447
|
return failure("INTEGRITY_FAILED", "terminal", "Inline delivery row collections disagree about zero delivery");
|
|
270
448
|
}
|
|
271
|
-
const
|
|
272
|
-
|
|
449
|
+
const sourceCollection = isRows(fetched) ? fetched : reportingRows ?? mediaBuyDeliveries ?? [];
|
|
450
|
+
const auxiliaryDeclaredLength = !isRows(fetched) && reportingRows !== void 0 ? mediaBuyDeliveriesLength : 0;
|
|
451
|
+
if (sourceDeclaredLength > INLINE_MAX_ROWS_V1 || auxiliaryDeclaredLength > INLINE_MAX_ROWS_V1) {
|
|
273
452
|
return failure("QUOTA_EXHAUSTED", "terminal", "Inline delivery fetch exceeded the row limit");
|
|
274
453
|
}
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
454
|
+
const sourceRowInputs = captureRowCollection(sourceCollection, sourceDeclaredLength);
|
|
455
|
+
const auxiliaryRowInputs = auxiliaryDeclaredLength > 0 ? captureRowCollection(mediaBuyDeliveries ?? [], auxiliaryDeclaredLength) : [];
|
|
456
|
+
let availabilityEvidence;
|
|
457
|
+
if (!isRows(fetched) && availabilityEvidenceSlot.kind === "unreadable") {
|
|
458
|
+
return failure("INTEGRITY_FAILED", "terminal", "Inline delivery availability evidence is invalid");
|
|
278
459
|
}
|
|
279
|
-
if (
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
460
|
+
if (!isRows(fetched) && availabilityEvidenceSlot.kind === "data") {
|
|
461
|
+
try {
|
|
462
|
+
availabilityEvidence = parseInlineAvailabilityEvidence(
|
|
463
|
+
availabilityEvidenceSlot.value,
|
|
464
|
+
request
|
|
465
|
+
);
|
|
466
|
+
} catch {
|
|
467
|
+
return failure("INTEGRITY_FAILED", "terminal", "Inline delivery availability evidence is invalid");
|
|
285
468
|
}
|
|
286
|
-
|
|
469
|
+
}
|
|
470
|
+
const captureLayout = captureLayoutFor(request);
|
|
471
|
+
const claimBearingRowCount = sourceRowInputs.length + (availabilityEvidenceSlot.kind === "data" ? auxiliaryRowInputs.length : 0);
|
|
472
|
+
if (workUnitsExceedCap(
|
|
473
|
+
claimBearingRowCount,
|
|
474
|
+
1 + request.requestedMetrics.length + request.requestedDimensions.length,
|
|
475
|
+
INLINE_MAX_VALIDATION_WORK_UNITS_V1
|
|
476
|
+
) || workUnitsExceedCap(
|
|
477
|
+
claimBearingRowCount,
|
|
478
|
+
INLINE_RETAINED_BYTES_PER_ROW_V1 + captureLayout.fields.length * INLINE_RETAINED_BYTES_PER_CLAIM_V1,
|
|
479
|
+
INLINE_MAX_VALIDATION_RETAINED_BYTES_V1
|
|
480
|
+
)) {
|
|
481
|
+
return failure("QUOTA_EXHAUSTED", "terminal", "Inline availability verification exceeded the work budget");
|
|
482
|
+
}
|
|
483
|
+
const strictClaims = availabilityEvidence !== void 0;
|
|
484
|
+
let scanBudget = INLINE_MAX_VALIDATION_SCAN_BYTES_V1;
|
|
485
|
+
const chargeScan = (units) => {
|
|
486
|
+
if (units > scanBudget) throw new InlineWorkBudgetExhaustedError();
|
|
487
|
+
scanBudget -= units;
|
|
488
|
+
};
|
|
489
|
+
const sourceReserved = [];
|
|
490
|
+
const auxiliaryReserved = [];
|
|
491
|
+
for (const [rows2, captured] of [
|
|
492
|
+
[sourceRowInputs, sourceReserved],
|
|
493
|
+
[auxiliaryRowInputs, auxiliaryReserved]
|
|
494
|
+
]) {
|
|
495
|
+
for (const row of rows2) {
|
|
496
|
+
const reserved = beginRowReserved(row);
|
|
497
|
+
captured.push(reserved);
|
|
498
|
+
if (reserved !== void 0 && (rowStatusIsUnavailable(reserved) || rowDeclaresPartialData(reserved))) {
|
|
499
|
+
return failure("PARTIAL_RESULT", "retryable", "Inline delivery fetch returned an unavailable row");
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
for (const reserved of [...sourceReserved, ...auxiliaryReserved]) {
|
|
504
|
+
if (reserved === void 0) continue;
|
|
505
|
+
readRowCurrency(reserved);
|
|
506
|
+
if (typeof reserved.currency === "string" && reserved.currency !== request.sourceSettings.currency) {
|
|
287
507
|
return failure("INTEGRITY_FAILED", "terminal", "Inline delivery row currency does not match source settings");
|
|
288
508
|
}
|
|
509
|
+
}
|
|
510
|
+
let sourceSnapshots;
|
|
511
|
+
let auxiliarySnapshots;
|
|
512
|
+
try {
|
|
513
|
+
const claimRowCount = sourceReserved.length + (strictClaims ? auxiliaryReserved.length : 0);
|
|
514
|
+
const store = createClaimStore(captureLayout, claimRowCount);
|
|
515
|
+
sourceSnapshots = sourceReserved.map(
|
|
516
|
+
(reserved, index) => captureRowSnapshot(reserved, store, index, strictClaims, chargeScan)
|
|
517
|
+
);
|
|
518
|
+
auxiliarySnapshots = auxiliaryReserved.map(
|
|
519
|
+
(reserved, index) => strictClaims ? captureRowSnapshot(reserved, store, sourceReserved.length + index, strictClaims, chargeScan) : captureRowIdentityOnly(reserved, store)
|
|
520
|
+
);
|
|
521
|
+
} catch (error) {
|
|
522
|
+
if (error instanceof InlineWorkBudgetExhaustedError) {
|
|
523
|
+
return failure("QUOTA_EXHAUSTED", "terminal", "Inline availability verification exceeded the scan budget");
|
|
524
|
+
}
|
|
525
|
+
return failure("INTEGRITY_FAILED", "terminal", "Inline delivery row contains invalid evidence values");
|
|
526
|
+
}
|
|
527
|
+
const allSnapshots = [...sourceSnapshots, ...auxiliarySnapshots];
|
|
528
|
+
if (validationWorkExceedsCap(
|
|
529
|
+
sourceSnapshots,
|
|
530
|
+
auxiliarySnapshots,
|
|
531
|
+
request,
|
|
532
|
+
availabilityEvidence !== void 0,
|
|
533
|
+
INLINE_MAX_VALIDATION_WORK_UNITS_V1
|
|
534
|
+
)) {
|
|
535
|
+
return failure("QUOTA_EXHAUSTED", "terminal", "Inline availability verification exceeded the work budget");
|
|
536
|
+
}
|
|
537
|
+
const admittedMediaBuyIds = new Set(
|
|
538
|
+
request.coverage.constituents.flatMap((constituent) => constituent.mediaBuyId ? [constituent.mediaBuyId] : [])
|
|
539
|
+
);
|
|
540
|
+
const sourceSnapshotsByMediaBuyId = groupSnapshotsByMediaBuyId(sourceSnapshots, admittedMediaBuyIds);
|
|
541
|
+
const auxiliarySnapshotsByMediaBuyId = groupSnapshotsByMediaBuyId(auxiliarySnapshots, admittedMediaBuyIds);
|
|
542
|
+
if (sourceSnapshots.length > 0) {
|
|
543
|
+
if (allSnapshots.some((snapshot) => !admittedMediaBuyIds.has(snapshot?.mediaBuyId ?? ""))) {
|
|
544
|
+
return failure("INTEGRITY_FAILED", "terminal", "Inline delivery fetch returned an out-of-scope row");
|
|
545
|
+
}
|
|
289
546
|
if (request.coverage.constituents.some((constituent) => {
|
|
290
547
|
if (constituent.constituentKind !== "media_buy" || !constituent.mediaBuyId) return true;
|
|
291
|
-
const constituentRows =
|
|
292
|
-
return constituentRows.
|
|
293
|
-
(
|
|
294
|
-
)
|
|
548
|
+
const constituentRows = sourceSnapshotsByMediaBuyId.get(constituent.mediaBuyId) ?? NO_SNAPSHOTS;
|
|
549
|
+
return constituentRows.some(
|
|
550
|
+
(snapshot) => request.requestedDimensions.some((dimension) => !snapshotHasDimension(snapshot, dimension))
|
|
551
|
+
) || availabilityEvidence === void 0 && (constituentRows.length === 0 || constituentRows.some(
|
|
552
|
+
(snapshot) => request.requestedMetrics.some((metric) => snapshotFieldValue(snapshot, metric) === void 0)
|
|
553
|
+
));
|
|
295
554
|
})) {
|
|
296
555
|
return failure(
|
|
297
556
|
"PARTIAL_RESULT",
|
|
@@ -300,37 +559,35 @@ async function executeAndSeal(deliveryFetch, offering, format, request, delivery
|
|
|
300
559
|
);
|
|
301
560
|
}
|
|
302
561
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
let rows;
|
|
310
|
-
try {
|
|
311
|
-
rows = sourceRows.map(
|
|
312
|
-
(row) => projectEvidenceRow(row, request, (upperBound) => {
|
|
313
|
-
if (upperBound > projectionBudget) throw new RangeError("Inline projection capacity exhausted");
|
|
314
|
-
projectionBudget -= upperBound;
|
|
315
|
-
})
|
|
562
|
+
if (availabilityEvidence !== void 0) {
|
|
563
|
+
const rowEvidenceFailure = validateSnapshotsAgainstAvailabilityEvidence(
|
|
564
|
+
sourceSnapshotsByMediaBuyId,
|
|
565
|
+
auxiliarySnapshotsByMediaBuyId,
|
|
566
|
+
request,
|
|
567
|
+
availabilityEvidence.cells
|
|
316
568
|
);
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
569
|
+
if (rowEvidenceFailure === "partial") {
|
|
570
|
+
return failure("PARTIAL_RESULT", "retryable", "Inline delivery rows do not prove every metric marked present");
|
|
571
|
+
}
|
|
572
|
+
if (rowEvidenceFailure === "integrity") {
|
|
573
|
+
return failure("INTEGRITY_FAILED", "terminal", "Inline delivery rows contradict availability evidence");
|
|
320
574
|
}
|
|
321
|
-
return failure("INTEGRITY_FAILED", "terminal", "Inline delivery row contains invalid evidence values");
|
|
322
575
|
}
|
|
323
576
|
const readsPartialPeriod = Date.parse(request.period.sourceReadCutoffAt) < Date.parse(request.period.end);
|
|
324
|
-
if (readsPartialPeriod && (isRows(fetched) ||
|
|
577
|
+
if (readsPartialPeriod && (isRows(fetched) || readResponseField("data_through") === void 0 || readResponseField("observed_at") === void 0)) {
|
|
325
578
|
return failure(
|
|
326
579
|
"PARTIAL_RESULT",
|
|
327
580
|
"retryable",
|
|
328
581
|
"Inline delivery fetch did not provide temporal evidence for the source read cutoff"
|
|
329
582
|
);
|
|
330
583
|
}
|
|
331
|
-
const observedAt = isRows(fetched) ? request.period.sourceReadCutoffAt : normalizeDeliveryInstant(
|
|
584
|
+
const observedAt = isRows(fetched) ? request.period.sourceReadCutoffAt : normalizeDeliveryInstant(
|
|
585
|
+
readResponseField("observed_at") ?? request.period.sourceReadCutoffAt,
|
|
586
|
+
deliveryDates,
|
|
587
|
+
request.period
|
|
588
|
+
);
|
|
332
589
|
const defaultDataThrough = request.publicationClass === "AUTHORITATIVE" ? request.period.end : Date.parse(request.period.sourceReadCutoffAt) < Date.parse(request.period.end) ? request.period.sourceReadCutoffAt : request.period.end;
|
|
333
|
-
const dataThrough = isRows(fetched) ? defaultDataThrough : normalizeDeliveryInstant(
|
|
590
|
+
const dataThrough = isRows(fetched) ? defaultDataThrough : normalizeDeliveryInstant(readResponseField("data_through") ?? defaultDataThrough, deliveryDates, request.period);
|
|
334
591
|
const acquiredAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
335
592
|
const startMs = Date.parse(request.period.start);
|
|
336
593
|
const endMs = Date.parse(request.period.end);
|
|
@@ -341,15 +598,110 @@ async function executeAndSeal(deliveryFetch, offering, format, request, delivery
|
|
|
341
598
|
if (request.publicationClass === "AUTHORITATIVE" && dataThroughMs < endMs) {
|
|
342
599
|
return failure("NOT_READY", "retryable", "Authoritative inline reporting has not reached period end");
|
|
343
600
|
}
|
|
344
|
-
if (![dataThroughMs, observedMs].every(Number.isFinite) || dataThroughMs < startMs || dataThroughMs > endMs || dataThroughMs > cutoffMs || dataThroughMs > observedMs || observedMs > acquiredMs ||
|
|
601
|
+
if (![dataThroughMs, observedMs].every(Number.isFinite) || dataThroughMs < startMs || dataThroughMs > endMs || dataThroughMs > cutoffMs || dataThroughMs > observedMs || observedMs > acquiredMs || sourceSnapshots.length > 0 && dataThroughMs <= startMs) {
|
|
345
602
|
return failure("SOURCE_PERMANENT", "terminal", "Inline delivery fetch returned invalid temporal evidence");
|
|
346
603
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
604
|
+
const declaredMetrics = new Map(offering.metrics.map((metric) => [metric.name, metric]));
|
|
605
|
+
const constituentIdsWithRows = new Set(
|
|
606
|
+
request.coverage.constituents.filter((constituent) => constituent.mediaBuyId && sourceSnapshotsByMediaBuyId.has(constituent.mediaBuyId)).map((constituent) => constituent.constituentId)
|
|
607
|
+
);
|
|
608
|
+
let projectedAvailability;
|
|
609
|
+
if (availabilityEvidence) {
|
|
610
|
+
try {
|
|
611
|
+
projectedAvailability = projectInlineAvailabilityEvidence(
|
|
612
|
+
availabilityEvidence.cells,
|
|
613
|
+
request,
|
|
614
|
+
declaredMetrics,
|
|
615
|
+
deliveryDates,
|
|
616
|
+
dataThrough,
|
|
617
|
+
sourceSnapshots.length,
|
|
618
|
+
constituentIdsWithRows
|
|
619
|
+
);
|
|
620
|
+
} catch {
|
|
621
|
+
return failure("INTEGRITY_FAILED", "terminal", "Inline delivery availability evidence is contradictory");
|
|
622
|
+
}
|
|
623
|
+
} else {
|
|
624
|
+
projectedAvailability = projectLegacyAvailability(request, declaredMetrics, dataThrough, sourceSnapshots.length);
|
|
625
|
+
}
|
|
626
|
+
if (request.coverage.expected === "full" && projectedAvailability.coverageStatus !== "full") {
|
|
627
|
+
return failure("PARTIAL_RESULT", "retryable", "Inline delivery evidence does not satisfy full requested coverage");
|
|
628
|
+
}
|
|
629
|
+
if (request.publicationClass === "AUTHORITATIVE" && projectedAvailability.metricAvailability.some(
|
|
630
|
+
(cell) => !["present", "explicit_zero"].includes(cell.status) || Date.parse(cell.dataThrough ?? "") !== endMs
|
|
631
|
+
)) {
|
|
632
|
+
return failure("PARTIAL_RESULT", "retryable", "Authoritative inline reporting has incomplete metric evidence");
|
|
633
|
+
}
|
|
634
|
+
const reservedBytes = reclaimer?.grantReservedBytes(scopeKey) ?? { global: 0, scope: 0 };
|
|
635
|
+
let plannedGlobalCredit = reservedBytes.global;
|
|
636
|
+
let plannedScopeCredit = reservedBytes.scope;
|
|
637
|
+
const globalRoom = () => capacities.total - storage.totalBytes + plannedGlobalCredit;
|
|
638
|
+
const scopeRoom = () => capacities.scope - (storage.scopeBytes.get(scopeKey) ?? 0) + plannedScopeCredit;
|
|
639
|
+
const capacity = () => Math.min(capacities.object, globalRoom(), scopeRoom());
|
|
640
|
+
const planMoreCapacity = () => {
|
|
641
|
+
for (; ; ) {
|
|
642
|
+
const freed = reclaimer?.plan(scopeKey, scopeRoom() <= globalRoom(), true);
|
|
643
|
+
if (freed === void 0) return false;
|
|
644
|
+
if (freed.bytes <= 0) continue;
|
|
645
|
+
plannedGlobalCredit += freed.bytes;
|
|
646
|
+
if (freed.sameScope) plannedScopeCredit += freed.bytes;
|
|
647
|
+
return true;
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
const growCapacity = (available) => {
|
|
651
|
+
observer?.onCapacityRequest?.();
|
|
652
|
+
if (!planMoreCapacity()) return void 0;
|
|
653
|
+
const grown = capacity();
|
|
654
|
+
return grown > available ? grown : void 0;
|
|
655
|
+
};
|
|
656
|
+
let remainingCapacity = capacity();
|
|
657
|
+
let projectionBudget = remainingCapacity;
|
|
658
|
+
let rows;
|
|
659
|
+
while (rows === void 0) {
|
|
660
|
+
projectionBudget = remainingCapacity;
|
|
661
|
+
try {
|
|
662
|
+
rows = sourceSnapshots.map(
|
|
663
|
+
(snapshot) => projectSnapshotRow(
|
|
664
|
+
snapshot,
|
|
665
|
+
request,
|
|
666
|
+
(upperBound) => {
|
|
667
|
+
if (upperBound > projectionBudget) throw new RangeError("Inline projection capacity exhausted");
|
|
668
|
+
projectionBudget -= upperBound;
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
allowMissingMetrics: true,
|
|
672
|
+
allowMissingDimensions: true,
|
|
673
|
+
strictMetricClaims: availabilityEvidence !== void 0,
|
|
674
|
+
includeDimensions: true
|
|
675
|
+
}
|
|
676
|
+
)
|
|
677
|
+
);
|
|
678
|
+
} catch (error) {
|
|
679
|
+
if (!(error instanceof RangeError)) {
|
|
680
|
+
return failure("INTEGRITY_FAILED", "terminal", "Inline delivery row contains invalid evidence values");
|
|
681
|
+
}
|
|
682
|
+
const grown = growCapacity(remainingCapacity);
|
|
683
|
+
if (grown === void 0) {
|
|
684
|
+
return failure("STAGING_FAILED", "terminal", "Inline delivery evidence exceeds the bounded replay capacity");
|
|
685
|
+
}
|
|
686
|
+
remainingCapacity = grown;
|
|
687
|
+
}
|
|
352
688
|
}
|
|
689
|
+
let encoded;
|
|
690
|
+
while (encoded === void 0) {
|
|
691
|
+
try {
|
|
692
|
+
encoded = encodeRows(rows, format.mediaType, remainingCapacity);
|
|
693
|
+
} catch (error) {
|
|
694
|
+
if (!(error instanceof RangeError)) {
|
|
695
|
+
return failure("INTEGRITY_FAILED", "terminal", "Inline delivery row contains invalid evidence values");
|
|
696
|
+
}
|
|
697
|
+
const grown = growCapacity(remainingCapacity);
|
|
698
|
+
if (grown === void 0) {
|
|
699
|
+
return failure("STAGING_FAILED", "terminal", "Inline delivery evidence exceeds the bounded replay capacity");
|
|
700
|
+
}
|
|
701
|
+
remainingCapacity = grown;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
const bytes = encoded;
|
|
353
705
|
const objectDigest = digest(bytes);
|
|
354
706
|
const objectRef = `inline-${executionNamespace.slice(0, 32)}`;
|
|
355
707
|
const generation = `sha256-${objectDigest}`;
|
|
@@ -363,25 +715,423 @@ async function executeAndSeal(deliveryFetch, offering, format, request, delivery
|
|
|
363
715
|
byteCount: bytes.byteLength,
|
|
364
716
|
rowCount: rows.length
|
|
365
717
|
};
|
|
366
|
-
|
|
718
|
+
let built;
|
|
719
|
+
try {
|
|
720
|
+
built = buildReportingSourceManifestV1({
|
|
721
|
+
level: "basic",
|
|
722
|
+
request,
|
|
723
|
+
stagedCommitRef: `inline-manifest-${executionNamespace.slice(0, 32)}`,
|
|
724
|
+
objects: [object],
|
|
725
|
+
completeness: {
|
|
726
|
+
terminal: true,
|
|
727
|
+
rowsComplete: true,
|
|
728
|
+
requestedGroupsComplete: true
|
|
729
|
+
},
|
|
730
|
+
controlTotals: [],
|
|
731
|
+
metricAvailability: projectedAvailability.metricAvailability,
|
|
732
|
+
coverage: {
|
|
733
|
+
status: projectedAvailability.coverageStatus,
|
|
734
|
+
constituents: projectedAvailability.coverageConstituents
|
|
735
|
+
},
|
|
736
|
+
observedAt,
|
|
737
|
+
dataThrough,
|
|
738
|
+
finalityEvidence: {
|
|
739
|
+
owner: "adapter",
|
|
740
|
+
basis: request.publicationClass === "PROVISIONAL_SNAPSHOT" ? "provisional_observation" : "source_declared",
|
|
741
|
+
observedAt,
|
|
742
|
+
...request.publicationClass === "AUTHORITATIVE" ? { evidenceRef: "get_media_buy_delivery.is_final" } : {}
|
|
743
|
+
},
|
|
744
|
+
explicitZero: projectedAvailability.explicitZero,
|
|
745
|
+
acquiredAt,
|
|
746
|
+
...rows.length === 0 ? {} : { eventTimeRange: { start: request.period.start, end: dataThrough } },
|
|
747
|
+
warnings: []
|
|
748
|
+
});
|
|
749
|
+
} catch (error) {
|
|
750
|
+
if (!availabilityEvidence) throw error;
|
|
751
|
+
if (error instanceof SourceBatchContractError && error.code === "SOURCE_MANIFEST_TOO_LARGE") {
|
|
752
|
+
return failure("QUOTA_EXHAUSTED", "terminal", "Inline reporting manifest exceeded the bounded size limit");
|
|
753
|
+
}
|
|
754
|
+
return failure("INTEGRITY_FAILED", "terminal", "Inline delivery availability evidence is contradictory");
|
|
755
|
+
}
|
|
756
|
+
if (Date.parse(deadlineAt) <= Date.now()) {
|
|
757
|
+
return failure("DEADLINE_EXCEEDED", "retryable", "Inline reporting execution deadline elapsed");
|
|
758
|
+
}
|
|
759
|
+
if (reclaimer !== void 0 && !reclaimer.commit(scopeKey)) {
|
|
760
|
+
return failure(
|
|
761
|
+
"STAGING_FAILED",
|
|
762
|
+
"terminal",
|
|
763
|
+
"Inline reporting could not reacquire the capacity a revoked reservation had promised"
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
storage.objects.set(objectRef, { request: structuredClone(request), generation, bytes: Uint8Array.from(bytes) });
|
|
767
|
+
storage.totalBytes += bytes.byteLength;
|
|
768
|
+
storage.scopeBytes.set(scopeKey, (storage.scopeBytes.get(scopeKey) ?? 0) + bytes.byteLength);
|
|
769
|
+
return {
|
|
770
|
+
ok: true,
|
|
771
|
+
response: completedReportingSourceResponseV1({ request, manifest: built.reference }),
|
|
772
|
+
manifestBytes: built.manifestBytes
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
function parseInlineAvailabilityEvidence(input, request) {
|
|
776
|
+
if (typeof input !== "object" || input === null) throw new TypeError("Availability evidence is not an envelope");
|
|
777
|
+
const envelope = snapshotOwnDataObject(input, INLINE_EVIDENCE_ENVELOPE_KEYS_V1);
|
|
778
|
+
const inputCells = envelope.cells;
|
|
779
|
+
const cellCount = Array.isArray(inputCells) ? boundedCollectionLength(inputCells) : void 0;
|
|
780
|
+
if (cellCount === void 0) throw new TypeError("Availability evidence cells are not a bounded array");
|
|
781
|
+
if (cellCount > SOURCE_BATCH_MANIFEST_MAX_METRIC_AVAILABILITY_V1) {
|
|
782
|
+
throw new TypeError("Availability evidence exceeds the cell limit");
|
|
783
|
+
}
|
|
784
|
+
const cellSnapshot = new Array(cellCount);
|
|
785
|
+
for (let index = 0; index < cellCount; index += 1) {
|
|
786
|
+
const cell = inputCells[index];
|
|
787
|
+
if (typeof cell !== "object" || cell === null || Array.isArray(cell)) {
|
|
788
|
+
throw new TypeError("Availability evidence cell is not an object");
|
|
789
|
+
}
|
|
790
|
+
cellSnapshot[index] = snapshotOwnDataObject(cell, INLINE_EVIDENCE_CELL_KEYS_V1);
|
|
791
|
+
}
|
|
792
|
+
const parsed = InlineReportingAvailabilityEvidenceV1Schema.parse({ ...envelope, cells: cellSnapshot });
|
|
793
|
+
const expected = new Set(
|
|
794
|
+
request.coverage.constituents.flatMap(
|
|
795
|
+
(constituent) => request.requestedMetrics.map((metric) => availabilityCellKey(constituent.constituentId, metric))
|
|
796
|
+
)
|
|
797
|
+
);
|
|
798
|
+
const seen = /* @__PURE__ */ new Set();
|
|
799
|
+
for (const cell of parsed.cells) {
|
|
800
|
+
const key = availabilityCellKey(cell.constituent_id, cell.metric);
|
|
801
|
+
if (!expected.has(key) || seen.has(key)) throw new TypeError("Availability cell is duplicate or out of scope");
|
|
802
|
+
seen.add(key);
|
|
803
|
+
}
|
|
804
|
+
if (seen.size !== expected.size) throw new TypeError("Availability evidence must cover the requested matrix");
|
|
805
|
+
const cellsByKey = new Map(parsed.cells.map((cell) => [availabilityCellKey(cell.constituent_id, cell.metric), cell]));
|
|
806
|
+
return {
|
|
807
|
+
...parsed,
|
|
808
|
+
cells: request.coverage.constituents.flatMap(
|
|
809
|
+
(constituent) => request.requestedMetrics.map((metric) => {
|
|
810
|
+
const cell = cellsByKey.get(availabilityCellKey(constituent.constituentId, metric));
|
|
811
|
+
if (!cell) throw new TypeError("Availability evidence must cover the requested matrix");
|
|
812
|
+
return cell;
|
|
813
|
+
})
|
|
814
|
+
)
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
const NO_SNAPSHOTS = [];
|
|
818
|
+
class InlineWorkBudgetExhaustedError extends Error {
|
|
819
|
+
}
|
|
820
|
+
const UNCLAIMED_V1 = { claimed: false };
|
|
821
|
+
function captureLayoutFor(request) {
|
|
822
|
+
const fields = [];
|
|
823
|
+
const indexOf = /* @__PURE__ */ new Map();
|
|
824
|
+
const reservedFields = /* @__PURE__ */ new Set();
|
|
825
|
+
const requestedAsMetric = new Set(request.requestedMetrics);
|
|
826
|
+
for (const field of [...request.requestedMetrics, ...request.requestedDimensions]) {
|
|
827
|
+
if (indexOf.has(field)) continue;
|
|
828
|
+
if (field === "media_buy_id" && !requestedAsMetric.has(field)) continue;
|
|
829
|
+
indexOf.set(field, fields.length);
|
|
830
|
+
fields.push(field);
|
|
831
|
+
if (INLINE_RESERVED_ROW_FIELDS_V1.includes(field)) reservedFields.add(field);
|
|
832
|
+
}
|
|
833
|
+
return { fields, indexOf, reservedFields };
|
|
834
|
+
}
|
|
835
|
+
const CLAIM_DIRECT_CLAIMED_V1 = 1 << 0;
|
|
836
|
+
const CLAIM_NESTED_CLAIMED_V1 = 1 << 1;
|
|
837
|
+
const CLAIM_DIRECT_VALID_V1 = 1 << 2;
|
|
838
|
+
const CLAIM_NESTED_VALID_V1 = 1 << 3;
|
|
839
|
+
const CLAIM_VALUE_IS_ZERO_V1 = 1 << 4;
|
|
840
|
+
const CLAIM_CLAIM_IS_ZERO_V1 = 1 << 5;
|
|
841
|
+
const CLAIM_DISAGREE_V1 = 1 << 6;
|
|
842
|
+
const INLINE_RESERVED_ROW_FIELDS_V1 = ["media_buy_id", "currency", "status", "partial_data", "totals"];
|
|
843
|
+
function beginRowReserved(row) {
|
|
844
|
+
const record = asRowRecord(row);
|
|
845
|
+
if (!record) return void 0;
|
|
846
|
+
return { record, status: ownDataValue(record, "status") };
|
|
847
|
+
}
|
|
848
|
+
function rowStatusIsUnavailable(reserved) {
|
|
849
|
+
const status = boundedLowerCaseStatus(reserved.status);
|
|
850
|
+
return status !== void 0 && INLINE_UNAVAILABLE_ROW_STATUSES_V1.includes(status);
|
|
851
|
+
}
|
|
852
|
+
function rowDeclaresPartialData(reserved) {
|
|
853
|
+
reserved.partialData = ownDataValue(reserved.record, "partial_data");
|
|
854
|
+
return reserved.partialData === true;
|
|
855
|
+
}
|
|
856
|
+
function readRowCurrency(reserved) {
|
|
857
|
+
reserved.currency = ownDataValue(reserved.record, "currency");
|
|
858
|
+
}
|
|
859
|
+
function readRowIdentity(reserved) {
|
|
860
|
+
reserved.mediaBuyId = ownDataValue(reserved.record, "media_buy_id");
|
|
861
|
+
}
|
|
862
|
+
function reservedFieldValue(reserved, field) {
|
|
863
|
+
switch (field) {
|
|
864
|
+
case "media_buy_id":
|
|
865
|
+
return reserved.mediaBuyId;
|
|
866
|
+
case "currency":
|
|
867
|
+
return reserved.currency;
|
|
868
|
+
case "status":
|
|
869
|
+
return reserved.status;
|
|
870
|
+
case "partial_data":
|
|
871
|
+
return reserved.partialData;
|
|
872
|
+
default:
|
|
873
|
+
return reserved.totals;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
function createClaimStore(layout, rowCount) {
|
|
877
|
+
const width = layout.fields.length;
|
|
878
|
+
return {
|
|
879
|
+
layout,
|
|
880
|
+
values: new Array(rowCount * width),
|
|
881
|
+
flags: new Uint8Array(rowCount * width)
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
function fieldSlotOf(snapshot, field) {
|
|
885
|
+
return snapshot.store.layout.indexOf.get(field) ?? -1;
|
|
886
|
+
}
|
|
887
|
+
function slotValue(snapshot, slot) {
|
|
888
|
+
return slot < 0 || snapshot.offset < 0 ? void 0 : snapshot.store.values[snapshot.offset + slot];
|
|
889
|
+
}
|
|
890
|
+
function slotFlags(snapshot, slot) {
|
|
891
|
+
return slot < 0 || snapshot.offset < 0 ? 0 : snapshot.store.flags[snapshot.offset + slot] ?? 0;
|
|
892
|
+
}
|
|
893
|
+
function snapshotFieldValue(snapshot, field) {
|
|
894
|
+
return slotValue(snapshot, fieldSlotOf(snapshot, field));
|
|
895
|
+
}
|
|
896
|
+
function captureRowSnapshot(reserved, store, rowIndex, strictClaims, chargeScan) {
|
|
897
|
+
if (!reserved) return void 0;
|
|
898
|
+
readRowIdentity(reserved);
|
|
899
|
+
const { record } = reserved;
|
|
900
|
+
const layout = store.layout;
|
|
901
|
+
const offset = rowIndex * layout.fields.length;
|
|
902
|
+
let totalsObserved = false;
|
|
903
|
+
let totalsRecord;
|
|
904
|
+
let totalsAliasesRow = false;
|
|
905
|
+
const observeTotals = () => {
|
|
906
|
+
if (!totalsObserved) {
|
|
907
|
+
totalsObserved = true;
|
|
908
|
+
reserved.totals = ownDataValue(record, "totals");
|
|
909
|
+
totalsRecord = typeof reserved.totals === "object" && reserved.totals !== null ? reserved.totals : void 0;
|
|
910
|
+
totalsAliasesRow = totalsRecord === record;
|
|
911
|
+
}
|
|
912
|
+
return reserved.totals;
|
|
913
|
+
};
|
|
914
|
+
for (let slot = 0; slot < layout.fields.length; slot += 1) {
|
|
915
|
+
const field = layout.fields[slot];
|
|
916
|
+
const direct = layout.reservedFields.has(field) ? claimOfValue(field === "totals" ? observeTotals() : reservedFieldValue(reserved, field)) : ownDataClaim(record, field);
|
|
917
|
+
const measurePasses = strictClaims ? 2 : 1;
|
|
918
|
+
chargeScan(measureScanWidth(direct.value) * measurePasses);
|
|
919
|
+
const measuredDirect = measureClaim(direct.value, strictClaims);
|
|
920
|
+
let nested = UNCLAIMED_V1;
|
|
921
|
+
let measuredNested = UNMEASURED_CLAIM_V1;
|
|
922
|
+
if (strictClaims || !measuredDirect.valid) {
|
|
923
|
+
observeTotals();
|
|
924
|
+
if (totalsRecord !== void 0) {
|
|
925
|
+
if (totalsAliasesRow) {
|
|
926
|
+
nested = direct;
|
|
927
|
+
measuredNested = measuredDirect;
|
|
928
|
+
} else {
|
|
929
|
+
nested = ownDataClaim(totalsRecord, field);
|
|
930
|
+
chargeScan(measureScanWidth(nested.value) * measurePasses);
|
|
931
|
+
measuredNested = measureClaim(nested.value, strictClaims);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
const resolved = measuredDirect.valid ? measuredDirect : measuredNested.valid ? measuredNested : void 0;
|
|
936
|
+
const claimed = direct.claimed ? measuredDirect : measuredNested;
|
|
937
|
+
let bits = 0;
|
|
938
|
+
if (direct.claimed) bits |= CLAIM_DIRECT_CLAIMED_V1;
|
|
939
|
+
if (nested.claimed) bits |= CLAIM_NESTED_CLAIMED_V1;
|
|
940
|
+
if (measuredDirect.valid) bits |= CLAIM_DIRECT_VALID_V1;
|
|
941
|
+
if (measuredNested.valid) bits |= CLAIM_NESTED_VALID_V1;
|
|
942
|
+
if (resolved?.isZero === true) bits |= CLAIM_VALUE_IS_ZERO_V1;
|
|
943
|
+
if (claimed.valid && claimed.isZero) bits |= CLAIM_CLAIM_IS_ZERO_V1;
|
|
944
|
+
if (strictClaims && direct.claimed && nested.claimed && measuredDirect.valid && measuredNested.valid && !Object.is(direct.value, nested.value)) {
|
|
945
|
+
chargeScan(canonicalScanWidth(direct.value) + canonicalScanWidth(nested.value));
|
|
946
|
+
const canonicalDirect = canonicalDecimalEvidence(measuredDirect.value);
|
|
947
|
+
const canonicalNested = canonicalDecimalEvidence(measuredNested.value);
|
|
948
|
+
if (canonicalDirect === void 0 || canonicalDirect !== canonicalNested) bits |= CLAIM_DISAGREE_V1;
|
|
949
|
+
}
|
|
950
|
+
store.values[offset + slot] = resolved?.value;
|
|
951
|
+
store.flags[offset + slot] = bits;
|
|
952
|
+
}
|
|
953
|
+
return {
|
|
954
|
+
store,
|
|
955
|
+
offset,
|
|
956
|
+
mediaBuyId: typeof reserved.mediaBuyId === "string" ? reserved.mediaBuyId : void 0
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
function captureRowIdentityOnly(reserved, store) {
|
|
960
|
+
if (!reserved) return void 0;
|
|
961
|
+
reserved.mediaBuyId = ownDataValue(reserved.record, "media_buy_id");
|
|
962
|
+
return {
|
|
963
|
+
store,
|
|
964
|
+
offset: INLINE_NO_CLAIMS_OFFSET_V1,
|
|
965
|
+
mediaBuyId: typeof reserved.mediaBuyId === "string" ? reserved.mediaBuyId : void 0
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
function claimOfValue(value) {
|
|
969
|
+
return value === void 0 ? UNCLAIMED_V1 : { claimed: true, value };
|
|
970
|
+
}
|
|
971
|
+
function asRowRecord(row) {
|
|
972
|
+
return typeof row !== "object" || row === null || Array.isArray(row) ? void 0 : row;
|
|
973
|
+
}
|
|
974
|
+
function boundedLowerCaseStatus(status) {
|
|
975
|
+
return typeof status === "string" && status.length <= INLINE_MAX_STATUS_CHARS_V1 ? status.toLowerCase() : void 0;
|
|
976
|
+
}
|
|
977
|
+
const UNMEASURED_CLAIM_V1 = { value: void 0, valid: false, isZero: false };
|
|
978
|
+
function measureClaim(value, strictClaims) {
|
|
979
|
+
if (!isEvidenceValue(value)) return UNMEASURED_CLAIM_V1;
|
|
980
|
+
return { value, valid: true, isZero: strictClaims ? isZeroEvidenceValue(value) : false };
|
|
981
|
+
}
|
|
982
|
+
function measureScanWidth(value) {
|
|
983
|
+
return typeof value === "string" ? value.length + 1 : 1;
|
|
984
|
+
}
|
|
985
|
+
function canonicalScanWidth(value) {
|
|
986
|
+
if (typeof value === "string") return value.length + 1;
|
|
987
|
+
if (typeof value !== "number") return 1;
|
|
988
|
+
return numericScanUnits(value);
|
|
989
|
+
}
|
|
990
|
+
function numericScanUnits(value) {
|
|
991
|
+
const printed = String(value);
|
|
992
|
+
const exponent = /[eE]([+-]?\d+)$/.exec(printed);
|
|
993
|
+
return printed.length + (exponent ? Math.abs(Number(exponent[1])) : 0) + 1;
|
|
994
|
+
}
|
|
995
|
+
function workUnitsExceedCap(count, unitsEach, cap) {
|
|
996
|
+
return unitsEach > 0 && count > Math.floor(cap / unitsEach);
|
|
997
|
+
}
|
|
998
|
+
function validationWorkExceedsCap(sourceSnapshots, auxiliarySnapshots, request, includeAuxiliary, cap) {
|
|
999
|
+
const unitsPerVisit = request.requestedMetrics.length + request.requestedDimensions.length;
|
|
1000
|
+
if (unitsPerVisit === 0) return false;
|
|
1001
|
+
const perConstituentCap = Math.floor(cap / unitsPerVisit);
|
|
1002
|
+
const sourceCounts = countSnapshotsByMediaBuyId(sourceSnapshots);
|
|
1003
|
+
const auxiliaryCounts = includeAuxiliary ? countSnapshotsByMediaBuyId(auxiliarySnapshots) : void 0;
|
|
1004
|
+
let work = 0;
|
|
1005
|
+
for (const constituent of request.coverage.constituents) {
|
|
1006
|
+
if (!constituent.mediaBuyId) continue;
|
|
1007
|
+
const visits = (sourceCounts.get(constituent.mediaBuyId) ?? 0) + (auxiliaryCounts?.get(constituent.mediaBuyId) ?? 0);
|
|
1008
|
+
if (visits > perConstituentCap) return true;
|
|
1009
|
+
work += visits * unitsPerVisit;
|
|
1010
|
+
if (work > cap) return true;
|
|
1011
|
+
}
|
|
1012
|
+
return false;
|
|
1013
|
+
}
|
|
1014
|
+
function countSnapshotsByMediaBuyId(snapshots) {
|
|
1015
|
+
const counts = /* @__PURE__ */ new Map();
|
|
1016
|
+
for (const snapshot of snapshots) {
|
|
1017
|
+
if (snapshot?.mediaBuyId === void 0) continue;
|
|
1018
|
+
counts.set(snapshot.mediaBuyId, (counts.get(snapshot.mediaBuyId) ?? 0) + 1);
|
|
1019
|
+
}
|
|
1020
|
+
return counts;
|
|
1021
|
+
}
|
|
1022
|
+
function groupSnapshotsByMediaBuyId(snapshots, admittedMediaBuyIds) {
|
|
1023
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
1024
|
+
for (const snapshot of snapshots) {
|
|
1025
|
+
if (!snapshot) continue;
|
|
1026
|
+
const mediaBuyId = snapshot.mediaBuyId;
|
|
1027
|
+
if (mediaBuyId === void 0 || !admittedMediaBuyIds.has(mediaBuyId)) continue;
|
|
1028
|
+
const existing = grouped.get(mediaBuyId);
|
|
1029
|
+
if (existing) existing.push(snapshot);
|
|
1030
|
+
else grouped.set(mediaBuyId, [snapshot]);
|
|
1031
|
+
}
|
|
1032
|
+
return grouped;
|
|
1033
|
+
}
|
|
1034
|
+
function snapshotHasDimension(snapshot, dimension) {
|
|
1035
|
+
return dimension === "media_buy_id" ? snapshot.mediaBuyId !== void 0 : snapshotFieldValue(snapshot, dimension) !== void 0;
|
|
1036
|
+
}
|
|
1037
|
+
function validateSnapshotsAgainstAvailabilityEvidence(sourceSnapshotsByMediaBuyId, auxiliarySnapshotsByMediaBuyId, request, cells) {
|
|
1038
|
+
const cellsByConstituent = /* @__PURE__ */ new Map();
|
|
1039
|
+
for (const constituent of request.coverage.constituents) cellsByConstituent.set(constituent.constituentId, []);
|
|
1040
|
+
for (const cell of cells) cellsByConstituent.get(cell.constituent_id)?.push(cell);
|
|
1041
|
+
let integrity = false;
|
|
1042
|
+
for (const constituent of request.coverage.constituents) {
|
|
1043
|
+
const sourceRows = constituent.mediaBuyId ? sourceSnapshotsByMediaBuyId.get(constituent.mediaBuyId) ?? NO_SNAPSHOTS : NO_SNAPSHOTS;
|
|
1044
|
+
const auxiliaryRows = constituent.mediaBuyId ? auxiliarySnapshotsByMediaBuyId.get(constituent.mediaBuyId) ?? NO_SNAPSHOTS : NO_SNAPSHOTS;
|
|
1045
|
+
for (const cell of cellsByConstituent.get(constituent.constituentId) ?? []) {
|
|
1046
|
+
if (cell.status === "present" && sourceRows.length === 0) return "partial";
|
|
1047
|
+
for (const snapshot of sourceRows) {
|
|
1048
|
+
const verdict = cellVerdictForSnapshot(cell, snapshot, true);
|
|
1049
|
+
if (verdict === "partial") return "partial";
|
|
1050
|
+
if (verdict === "integrity") integrity = true;
|
|
1051
|
+
}
|
|
1052
|
+
for (const snapshot of auxiliaryRows) {
|
|
1053
|
+
const verdict = cellVerdictForSnapshot(cell, snapshot, false);
|
|
1054
|
+
if (verdict === "partial") return "partial";
|
|
1055
|
+
if (verdict === "integrity") integrity = true;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
return integrity ? "integrity" : void 0;
|
|
1060
|
+
}
|
|
1061
|
+
function cellVerdictForSnapshot(cell, snapshot, isSourceRow) {
|
|
1062
|
+
const slot = fieldSlotOf(snapshot, cell.metric);
|
|
1063
|
+
const flags = slotFlags(snapshot, slot);
|
|
1064
|
+
if (isSourceRow) {
|
|
1065
|
+
if (cell.status === "present" && slotValue(snapshot, slot) === void 0) return "partial";
|
|
1066
|
+
if (cell.status === "explicit_zero" && (flags & CLAIM_VALUE_IS_ZERO_V1) === 0) return "integrity";
|
|
1067
|
+
}
|
|
1068
|
+
const directClaimed = (flags & CLAIM_DIRECT_CLAIMED_V1) !== 0;
|
|
1069
|
+
const nestedClaimed = (flags & CLAIM_NESTED_CLAIMED_V1) !== 0;
|
|
1070
|
+
const directValid = (flags & CLAIM_DIRECT_VALID_V1) !== 0;
|
|
1071
|
+
const nestedValid = (flags & CLAIM_NESTED_VALID_V1) !== 0;
|
|
1072
|
+
if (directClaimed && !directValid || nestedClaimed && !nestedValid) return "integrity";
|
|
1073
|
+
const claimValid = directClaimed ? directValid : nestedValid;
|
|
1074
|
+
if ((flags & CLAIM_DISAGREE_V1) !== 0) return "integrity";
|
|
1075
|
+
if (!claimValid) return void 0;
|
|
1076
|
+
if (cell.status === "explicit_zero" && (flags & CLAIM_CLAIM_IS_ZERO_V1) === 0) return "integrity";
|
|
1077
|
+
return INLINE_UNAVAILABLE_CELL_STATUSES_V1.includes(cell.status) ? "integrity" : void 0;
|
|
1078
|
+
}
|
|
1079
|
+
function projectInlineAvailabilityEvidence(cells, request, declaredMetrics, deliveryDates, manifestDataThrough, rowCount, constituentIdsWithRows) {
|
|
1080
|
+
const startMs = Date.parse(request.period.start);
|
|
1081
|
+
const manifestDataThroughMs = Date.parse(manifestDataThrough);
|
|
1082
|
+
const metricAvailability = cells.map((cell) => {
|
|
1083
|
+
const metric = declaredMetrics.get(cell.metric);
|
|
1084
|
+
if (!metric) throw new TypeError(`Offering does not declare ${cell.metric}`);
|
|
1085
|
+
const dataThrough = cell.data_through ? normalizeDeliveryInstant(cell.data_through, deliveryDates, request.period) : void 0;
|
|
1086
|
+
const dataThroughMs = dataThrough === void 0 ? void 0 : Date.parse(dataThrough);
|
|
1087
|
+
if (dataThroughMs !== void 0 && (!Number.isFinite(dataThroughMs) || dataThroughMs < startMs || dataThroughMs > manifestDataThroughMs || ["present", "explicit_zero"].includes(cell.status) && constituentIdsWithRows.has(cell.constituent_id) && dataThroughMs === startMs)) {
|
|
1088
|
+
throw new TypeError("Availability dataThrough exceeds the manifest window");
|
|
1089
|
+
}
|
|
1090
|
+
return {
|
|
1091
|
+
constituentId: cell.constituent_id,
|
|
1092
|
+
metric: cell.metric,
|
|
1093
|
+
semanticContractId: metric.semanticContractId,
|
|
1094
|
+
semanticContractVersion: metric.semanticContractVersion,
|
|
1095
|
+
semanticContractSha256: metric.semanticContractSha256,
|
|
1096
|
+
status: cell.status,
|
|
1097
|
+
...dataThrough ? { dataThrough } : {},
|
|
1098
|
+
...cell.reason ? { reason: cell.reason } : {}
|
|
1099
|
+
};
|
|
1100
|
+
});
|
|
1101
|
+
const coverageConstituents = request.coverage.constituents.map((constituent) => {
|
|
1102
|
+
const constituentCells = metricAvailability.filter((cell) => cell.constituentId === constituent.constituentId);
|
|
1103
|
+
const status = rollUpInlineConstituentStatus(constituentCells.map((cell) => cell.status));
|
|
1104
|
+
const dataThrough = earliestDataThrough(constituentCells);
|
|
1105
|
+
const reason = constituentCells.find((cell) => cell.reason)?.reason;
|
|
1106
|
+
if (!["present", "explicit_zero"].includes(status) && !reason) {
|
|
1107
|
+
throw new TypeError("Unavailable constituent roll-up requires supplied evidence");
|
|
1108
|
+
}
|
|
1109
|
+
return {
|
|
1110
|
+
...constituent,
|
|
1111
|
+
status,
|
|
1112
|
+
...dataThrough ? { dataThrough } : {},
|
|
1113
|
+
...reason && !["present", "explicit_zero"].includes(status) ? { reason } : {}
|
|
1114
|
+
};
|
|
1115
|
+
});
|
|
1116
|
+
const allCellsExplicitZero = metricAvailability.every((cell) => cell.status === "explicit_zero");
|
|
1117
|
+
if (rowCount === 0 && metricAvailability.some((cell) => ["present", "explicit_zero"].includes(cell.status)) && !allCellsExplicitZero) {
|
|
1118
|
+
throw new TypeError("Zero-row evidence has contradictory available cells");
|
|
1119
|
+
}
|
|
1120
|
+
const fullyCovered = coverageConstituents.filter(
|
|
1121
|
+
(constituent) => ["present", "explicit_zero"].includes(constituent.status)
|
|
1122
|
+
).length;
|
|
1123
|
+
const someCoverage = fullyCovered > 0 || coverageConstituents.some((constituent) => constituent.status === "partial");
|
|
1124
|
+
return {
|
|
1125
|
+
metricAvailability,
|
|
1126
|
+
coverageConstituents,
|
|
1127
|
+
coverageStatus: fullyCovered === coverageConstituents.length ? "full" : someCoverage ? "partial" : "none",
|
|
1128
|
+
explicitZero: rowCount === 0 && allCellsExplicitZero
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
function projectLegacyAvailability(request, declaredMetrics, dataThrough, rowCount) {
|
|
1132
|
+
const explicitZero = rowCount === 0;
|
|
367
1133
|
const status = explicitZero ? "explicit_zero" : "present";
|
|
368
|
-
|
|
369
|
-
...constituent,
|
|
370
|
-
status,
|
|
371
|
-
dataThrough
|
|
372
|
-
}));
|
|
373
|
-
const declaredMetrics = new Map(offering.metrics.map((metric) => [metric.name, metric]));
|
|
374
|
-
const built = buildReportingSourceManifestV1({
|
|
375
|
-
level: "basic",
|
|
376
|
-
request,
|
|
377
|
-
stagedCommitRef: `inline-manifest-${executionNamespace.slice(0, 32)}`,
|
|
378
|
-
objects: [object],
|
|
379
|
-
completeness: {
|
|
380
|
-
terminal: true,
|
|
381
|
-
rowsComplete: true,
|
|
382
|
-
requestedGroupsComplete: true
|
|
383
|
-
},
|
|
384
|
-
controlTotals: [],
|
|
1134
|
+
return {
|
|
385
1135
|
metricAvailability: request.coverage.constituents.flatMap(
|
|
386
1136
|
(constituent) => request.requestedMetrics.map((metricName) => {
|
|
387
1137
|
const metric = declaredMetrics.get(metricName);
|
|
@@ -397,35 +1147,34 @@ async function executeAndSeal(deliveryFetch, offering, format, request, delivery
|
|
|
397
1147
|
};
|
|
398
1148
|
})
|
|
399
1149
|
),
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
owner: "adapter",
|
|
408
|
-
basis: request.publicationClass === "PROVISIONAL_SNAPSHOT" ? "provisional_observation" : "source_declared",
|
|
409
|
-
observedAt,
|
|
410
|
-
...request.publicationClass === "AUTHORITATIVE" ? { evidenceRef: "get_media_buy_delivery.is_final" } : {}
|
|
411
|
-
},
|
|
412
|
-
explicitZero,
|
|
413
|
-
acquiredAt,
|
|
414
|
-
...explicitZero ? {} : { eventTimeRange: { start: request.period.start, end: dataThrough } },
|
|
415
|
-
warnings: []
|
|
416
|
-
});
|
|
417
|
-
if (Date.parse(deadlineAt) <= Date.now()) {
|
|
418
|
-
return failure("DEADLINE_EXCEEDED", "retryable", "Inline reporting execution deadline elapsed");
|
|
419
|
-
}
|
|
420
|
-
storage.objects.set(objectRef, { request: structuredClone(request), generation, bytes: Uint8Array.from(bytes) });
|
|
421
|
-
storage.totalBytes += bytes.byteLength;
|
|
422
|
-
storage.scopeBytes.set(scopeKey, (storage.scopeBytes.get(scopeKey) ?? 0) + bytes.byteLength);
|
|
423
|
-
return {
|
|
424
|
-
ok: true,
|
|
425
|
-
response: completedReportingSourceResponseV1({ request, manifest: built.reference }),
|
|
426
|
-
manifestBytes: built.manifestBytes
|
|
1150
|
+
coverageConstituents: request.coverage.constituents.map((constituent) => ({
|
|
1151
|
+
...constituent,
|
|
1152
|
+
status,
|
|
1153
|
+
dataThrough
|
|
1154
|
+
})),
|
|
1155
|
+
coverageStatus: "full",
|
|
1156
|
+
explicitZero
|
|
427
1157
|
};
|
|
428
1158
|
}
|
|
1159
|
+
function rollUpInlineConstituentStatus(statuses) {
|
|
1160
|
+
if (statuses.every((status) => status === "explicit_zero")) return "explicit_zero";
|
|
1161
|
+
if (statuses.every((status) => status === "present" || status === "explicit_zero")) return "present";
|
|
1162
|
+
if (statuses.every((status) => status === "unsupported")) return "unsupported";
|
|
1163
|
+
if (statuses.every((status) => status === "missing")) return "missing";
|
|
1164
|
+
if (statuses.every((status) => ["unsupported", "delayed", "missing"].includes(status))) return "delayed";
|
|
1165
|
+
if (statuses.every((status) => ["unsupported", "delayed", "stale", "missing"].includes(status))) return "stale";
|
|
1166
|
+
return "partial";
|
|
1167
|
+
}
|
|
1168
|
+
function earliestDataThrough(cells) {
|
|
1169
|
+
return cells.reduce((earliest, cell) => {
|
|
1170
|
+
if (!cell.dataThrough) return earliest;
|
|
1171
|
+
if (!earliest || Date.parse(cell.dataThrough) < Date.parse(earliest)) return cell.dataThrough;
|
|
1172
|
+
return earliest;
|
|
1173
|
+
}, void 0);
|
|
1174
|
+
}
|
|
1175
|
+
function availabilityCellKey(constituentId, metric) {
|
|
1176
|
+
return `${constituentId}\0${metric}`;
|
|
1177
|
+
}
|
|
429
1178
|
function encodeRows(rows, mediaType, maxBytes) {
|
|
430
1179
|
if (!Number.isSafeInteger(maxBytes) || maxBytes < 0) throw new RangeError("Inline staging capacity exhausted");
|
|
431
1180
|
const chunks = [];
|
|
@@ -531,29 +1280,50 @@ async function awaitInlineExecution(entry, signal, deadlineAt) {
|
|
|
531
1280
|
if (releaseWaiter) entry.waiters -= 1;
|
|
532
1281
|
}
|
|
533
1282
|
}
|
|
534
|
-
function
|
|
535
|
-
|
|
536
|
-
const value = ownDataValue(row, "media_buy_id");
|
|
537
|
-
return typeof value === "string" ? value : void 0;
|
|
1283
|
+
function isEvidenceValue(value) {
|
|
1284
|
+
return typeof value === "number" && Number.isFinite(value) || typeof value === "string" && value.length > 0 && Buffer.byteLength(value, "utf8") <= INLINE_MAX_OBJECT_BYTES_V1;
|
|
538
1285
|
}
|
|
539
|
-
function
|
|
540
|
-
|
|
1286
|
+
function canonicalDecimalEvidence(value) {
|
|
1287
|
+
let raw;
|
|
1288
|
+
if (typeof value === "number") {
|
|
1289
|
+
if (!Number.isFinite(value)) return void 0;
|
|
1290
|
+
raw = plainDecimalNumberEvidence(value);
|
|
1291
|
+
} else {
|
|
1292
|
+
raw = value.trim();
|
|
1293
|
+
}
|
|
1294
|
+
const parts = /^(-?)(\d+)(?:\.(\d+))?$/.exec(raw);
|
|
1295
|
+
if (!parts) return void 0;
|
|
1296
|
+
const integer = trimLeadingZeroDigits(parts[2] ?? "");
|
|
1297
|
+
const fraction = trimTrailingZeroDigits(parts[3] ?? "");
|
|
1298
|
+
const magnitude = fraction ? `${integer}.${fraction}` : integer;
|
|
1299
|
+
return magnitude === "0" ? "0" : `${parts[1] ?? ""}${magnitude}`;
|
|
541
1300
|
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
const totals = ownDataValue(record, "totals");
|
|
548
|
-
if (typeof totals !== "object" || totals === null) return void 0;
|
|
549
|
-
const nested = ownDataValue(totals, field);
|
|
550
|
-
return isEvidenceValue(nested) ? nested : void 0;
|
|
1301
|
+
const ZERO_CHAR_CODE = 48;
|
|
1302
|
+
function trimLeadingZeroDigits(digits) {
|
|
1303
|
+
let start = 0;
|
|
1304
|
+
while (start + 1 < digits.length && digits.charCodeAt(start) === ZERO_CHAR_CODE) start += 1;
|
|
1305
|
+
return digits.slice(start);
|
|
551
1306
|
}
|
|
552
|
-
function
|
|
553
|
-
|
|
1307
|
+
function trimTrailingZeroDigits(digits) {
|
|
1308
|
+
let end = digits.length;
|
|
1309
|
+
while (end > 0 && digits.charCodeAt(end - 1) === ZERO_CHAR_CODE) end -= 1;
|
|
1310
|
+
return digits.slice(0, end);
|
|
1311
|
+
}
|
|
1312
|
+
function plainDecimalNumberEvidence(value) {
|
|
1313
|
+
const raw = String(value);
|
|
1314
|
+
const parts = /^(-?)(\d+)(?:\.(\d+))?[eE]([+-]?\d+)$/.exec(raw);
|
|
1315
|
+
if (!parts) return raw;
|
|
1316
|
+
const exponent = Number(parts[4]);
|
|
1317
|
+
if (!Number.isInteger(exponent) || Math.abs(exponent) > INLINE_MAX_DECIMAL_EXPONENT_V1) return raw;
|
|
1318
|
+
const sign = parts[1] ?? "";
|
|
1319
|
+
const digits = `${parts[2] ?? ""}${parts[3] ?? ""}`;
|
|
1320
|
+
const pointIndex = (parts[2] ?? "").length + exponent;
|
|
1321
|
+
if (pointIndex <= 0) return `${sign}0.${"0".repeat(-pointIndex)}${digits}`;
|
|
1322
|
+
if (pointIndex >= digits.length) return `${sign}${digits}${"0".repeat(pointIndex - digits.length)}`;
|
|
1323
|
+
return `${sign}${digits.slice(0, pointIndex)}.${digits.slice(pointIndex)}`;
|
|
554
1324
|
}
|
|
555
|
-
function
|
|
556
|
-
return
|
|
1325
|
+
function isZeroEvidenceValue(value) {
|
|
1326
|
+
return typeof value === "number" ? value === 0 : /^\s*-?0+(?:\.0+)?\s*$/.test(value);
|
|
557
1327
|
}
|
|
558
1328
|
function isRows(value) {
|
|
559
1329
|
return Array.isArray(value);
|
|
@@ -562,41 +1332,122 @@ function ownDataValue(record, field) {
|
|
|
562
1332
|
const descriptor = Object.getOwnPropertyDescriptor(record, field);
|
|
563
1333
|
return descriptor && "value" in descriptor ? descriptor.value : void 0;
|
|
564
1334
|
}
|
|
565
|
-
function
|
|
566
|
-
|
|
567
|
-
|
|
1335
|
+
function ownDataClaim(record, field) {
|
|
1336
|
+
const descriptor = Object.getOwnPropertyDescriptor(record, field);
|
|
1337
|
+
return descriptor && "value" in descriptor && descriptor.value !== void 0 ? { claimed: true, value: descriptor.value } : { claimed: false };
|
|
1338
|
+
}
|
|
1339
|
+
function snapshotOwnDataObject(record, allowedKeys) {
|
|
1340
|
+
const keys = Reflect.ownKeys(record);
|
|
1341
|
+
if (keys.length > INLINE_MAX_EVIDENCE_OBJECT_KEYS_V1) {
|
|
1342
|
+
throw new TypeError("Availability evidence object declares too many keys");
|
|
1343
|
+
}
|
|
1344
|
+
for (const key of keys) {
|
|
1345
|
+
if (typeof key !== "string" || !allowedKeys.includes(key)) {
|
|
1346
|
+
throw new TypeError("Availability evidence object declares an unknown key");
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
const snapshot = {};
|
|
1350
|
+
for (const key of keys) {
|
|
1351
|
+
const descriptor = Object.getOwnPropertyDescriptor(record, key);
|
|
1352
|
+
if (!descriptor || !("value" in descriptor)) throw new TypeError("Availability evidence field is not readable");
|
|
1353
|
+
if (typeof descriptor.value === "string" && descriptor.value.length > INLINE_MAX_EVIDENCE_FIELD_CHARS_V1) {
|
|
1354
|
+
throw new TypeError("Availability evidence field exceeds its bounded length");
|
|
1355
|
+
}
|
|
1356
|
+
snapshot[key] = descriptor.value;
|
|
1357
|
+
}
|
|
1358
|
+
return snapshot;
|
|
1359
|
+
}
|
|
1360
|
+
function createResponseFieldReader(record) {
|
|
1361
|
+
const observed = /* @__PURE__ */ new Map();
|
|
1362
|
+
return (field) => {
|
|
1363
|
+
if (observed.has(field)) return observed.get(field);
|
|
1364
|
+
const value = record?.[field];
|
|
1365
|
+
observed.set(field, value);
|
|
1366
|
+
return value;
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1369
|
+
function asStringOrUndefined(value) {
|
|
568
1370
|
return typeof value === "string" ? value : void 0;
|
|
569
1371
|
}
|
|
570
|
-
function
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
return
|
|
575
|
-
}
|
|
576
|
-
function
|
|
577
|
-
if (
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
1372
|
+
function looseCount(value) {
|
|
1373
|
+
return value ?? 0;
|
|
1374
|
+
}
|
|
1375
|
+
function lengthOfUnknown(value) {
|
|
1376
|
+
return value?.length;
|
|
1377
|
+
}
|
|
1378
|
+
function boundedCollectionLength(rows) {
|
|
1379
|
+
if (rows === void 0) return 0;
|
|
1380
|
+
const declared = rows.length;
|
|
1381
|
+
return typeof declared === "number" && Number.isSafeInteger(declared) && declared >= 0 ? declared : void 0;
|
|
1382
|
+
}
|
|
1383
|
+
function captureRowCollection(rows, declaredLength) {
|
|
1384
|
+
const captured = new Array(declaredLength);
|
|
1385
|
+
for (let index = 0; index < declaredLength; index += 1) captured[index] = rows[index];
|
|
1386
|
+
return captured;
|
|
1387
|
+
}
|
|
1388
|
+
function resolveOwnDataSlot(record, field) {
|
|
1389
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1390
|
+
let current = record;
|
|
1391
|
+
for (let depth = 0; current !== null; depth += 1) {
|
|
1392
|
+
if (depth >= INLINE_MAX_PROTOTYPE_CHAIN_DEPTH_V1 || visited.has(current)) return { kind: "unreadable" };
|
|
1393
|
+
visited.add(current);
|
|
1394
|
+
let descriptor;
|
|
1395
|
+
let prototype = null;
|
|
1396
|
+
try {
|
|
1397
|
+
descriptor = Object.getOwnPropertyDescriptor(current, field);
|
|
1398
|
+
if (!descriptor) prototype = Object.getPrototypeOf(current);
|
|
1399
|
+
} catch {
|
|
1400
|
+
return { kind: "unreadable" };
|
|
1401
|
+
}
|
|
1402
|
+
if (descriptor) {
|
|
1403
|
+
if (!("value" in descriptor)) return { kind: "unreadable" };
|
|
1404
|
+
if (descriptor.value === void 0) return { kind: "absent" };
|
|
1405
|
+
return current === record ? { kind: "data", value: descriptor.value } : { kind: "unreadable" };
|
|
1406
|
+
}
|
|
1407
|
+
current = prototype;
|
|
1408
|
+
}
|
|
1409
|
+
return { kind: "absent" };
|
|
1410
|
+
}
|
|
1411
|
+
function projectSnapshotRow(snapshot, request, consumeBudget, options) {
|
|
1412
|
+
if (!snapshot) throw new TypeError("Invalid row");
|
|
1413
|
+
const projected = { media_buy_id: snapshot.mediaBuyId };
|
|
1414
|
+
if (options.includeDimensions) {
|
|
1415
|
+
for (const dimension of request.requestedDimensions) {
|
|
1416
|
+
if (dimension === "media_buy_id") continue;
|
|
1417
|
+
const value = snapshotFieldValue(snapshot, dimension);
|
|
1418
|
+
if (value === void 0) {
|
|
1419
|
+
if (options.allowMissingDimensions) continue;
|
|
1420
|
+
throw new TypeError("Invalid dimension evidence");
|
|
1421
|
+
}
|
|
1422
|
+
consumeBudget(jsonEvidenceUpperBound(value));
|
|
1423
|
+
projected[dimension] = value;
|
|
1424
|
+
}
|
|
586
1425
|
}
|
|
587
|
-
const totals = ownDataValue(record, "totals");
|
|
588
1426
|
const projectedTotals = {};
|
|
589
1427
|
for (const metric of request.requestedMetrics) {
|
|
590
|
-
const
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
1428
|
+
const slot = fieldSlotOf(snapshot, metric);
|
|
1429
|
+
const flags = slotFlags(snapshot, slot);
|
|
1430
|
+
const directClaimed = (flags & CLAIM_DIRECT_CLAIMED_V1) !== 0;
|
|
1431
|
+
const directValid = (flags & CLAIM_DIRECT_VALID_V1) !== 0;
|
|
1432
|
+
const value = slotValue(snapshot, slot);
|
|
1433
|
+
let directValue = false;
|
|
1434
|
+
if (options.strictMetricClaims) {
|
|
1435
|
+
if (directClaimed && !directValid) throw new TypeError("Invalid metric evidence");
|
|
1436
|
+
if ((flags & CLAIM_NESTED_CLAIMED_V1) !== 0 && (flags & CLAIM_NESTED_VALID_V1) === 0) {
|
|
1437
|
+
throw new TypeError("Invalid metric evidence");
|
|
1438
|
+
}
|
|
1439
|
+
if ((flags & CLAIM_DISAGREE_V1) !== 0) throw new TypeError("Contradictory metric evidence");
|
|
1440
|
+
directValue = directClaimed;
|
|
1441
|
+
} else {
|
|
1442
|
+
directValue = directValid;
|
|
1443
|
+
}
|
|
1444
|
+
if (value === void 0) {
|
|
1445
|
+
if (options.allowMissingMetrics) continue;
|
|
1446
|
+
throw new TypeError("Invalid metric evidence");
|
|
595
1447
|
}
|
|
596
|
-
|
|
597
|
-
if (
|
|
598
|
-
|
|
599
|
-
projectedTotals[metric] = total;
|
|
1448
|
+
consumeBudget(jsonEvidenceUpperBound(value));
|
|
1449
|
+
if (directValue) projected[metric] = value;
|
|
1450
|
+
else projectedTotals[metric] = value;
|
|
600
1451
|
}
|
|
601
1452
|
if (Object.keys(projectedTotals).length > 0) projected.totals = projectedTotals;
|
|
602
1453
|
return projected;
|
|
@@ -607,6 +1458,154 @@ function inlineDeliveryDates(request) {
|
|
|
607
1458
|
if (start !== request.period.sourceLocalDate) throw new RangeError("sourceLocalDate does not match period start");
|
|
608
1459
|
return { start, end };
|
|
609
1460
|
}
|
|
1461
|
+
function stagedObjectRef(executionKey) {
|
|
1462
|
+
return `inline-${executionKey.slice(0, 32)}`;
|
|
1463
|
+
}
|
|
1464
|
+
function stagedBytesOf(storage, executionKey) {
|
|
1465
|
+
return storage.objects.get(stagedObjectRef(executionKey))?.bytes.byteLength ?? 0;
|
|
1466
|
+
}
|
|
1467
|
+
function planReclaim(executions, excluded, scopeKey) {
|
|
1468
|
+
for (const [key, entry] of executions) {
|
|
1469
|
+
if (entry.pending || entry.waiters > 0 || entry.reservation !== void 0) continue;
|
|
1470
|
+
if (scopeKey !== void 0 && entry.scopeKey !== scopeKey) continue;
|
|
1471
|
+
if (excluded.includes(key)) continue;
|
|
1472
|
+
return key;
|
|
1473
|
+
}
|
|
1474
|
+
return void 0;
|
|
1475
|
+
}
|
|
1476
|
+
function commitReclaim(executions, storage, key) {
|
|
1477
|
+
const entry = executions.get(key);
|
|
1478
|
+
if (!entry) return;
|
|
1479
|
+
executions.delete(key);
|
|
1480
|
+
const objectRef = stagedObjectRef(key);
|
|
1481
|
+
const stored = storage.objects.get(objectRef);
|
|
1482
|
+
if (!stored) return;
|
|
1483
|
+
storage.objects.delete(objectRef);
|
|
1484
|
+
storage.totalBytes -= stored.bytes.byteLength;
|
|
1485
|
+
const remaining = (storage.scopeBytes.get(entry.scopeKey) ?? 0) - stored.bytes.byteLength;
|
|
1486
|
+
if (remaining > 0) storage.scopeBytes.set(entry.scopeKey, remaining);
|
|
1487
|
+
else storage.scopeBytes.delete(entry.scopeKey);
|
|
1488
|
+
}
|
|
1489
|
+
function createAdmissionReclaimer(executions, storage) {
|
|
1490
|
+
const planned = [];
|
|
1491
|
+
const token = {};
|
|
1492
|
+
const owns = (key) => executions.get(key)?.reservation === token;
|
|
1493
|
+
let settled = false;
|
|
1494
|
+
return {
|
|
1495
|
+
plan(scopeKey, scopeOnly, credit = false) {
|
|
1496
|
+
const victim = planReclaim(
|
|
1497
|
+
executions,
|
|
1498
|
+
planned.map((entry2) => entry2.key),
|
|
1499
|
+
scopeOnly ? scopeKey : void 0
|
|
1500
|
+
);
|
|
1501
|
+
if (victim === void 0) return void 0;
|
|
1502
|
+
const entry = executions.get(victim);
|
|
1503
|
+
if (entry) entry.reservation = token;
|
|
1504
|
+
const sameScope = entry?.scopeKey === scopeKey;
|
|
1505
|
+
const bytes = stagedBytesOf(storage, victim);
|
|
1506
|
+
planned.push({
|
|
1507
|
+
key: victim,
|
|
1508
|
+
sameScope,
|
|
1509
|
+
grantedGlobal: credit ? bytes : 0,
|
|
1510
|
+
grantedScope: credit && sameScope ? bytes : 0
|
|
1511
|
+
});
|
|
1512
|
+
return { bytes, sameScope };
|
|
1513
|
+
},
|
|
1514
|
+
plannedInScope(scopeKey) {
|
|
1515
|
+
return planned.filter((entry) => owns(entry.key) && executions.get(entry.key)?.scopeKey === scopeKey).length;
|
|
1516
|
+
},
|
|
1517
|
+
grantReservedBytes(scopeKey) {
|
|
1518
|
+
let global = 0;
|
|
1519
|
+
let scope = 0;
|
|
1520
|
+
for (const victim of planned) {
|
|
1521
|
+
if (!owns(victim.key)) {
|
|
1522
|
+
victim.grantedGlobal = 0;
|
|
1523
|
+
victim.grantedScope = 0;
|
|
1524
|
+
continue;
|
|
1525
|
+
}
|
|
1526
|
+
const bytes = stagedBytesOf(storage, victim.key);
|
|
1527
|
+
const sameScope = executions.get(victim.key)?.scopeKey === scopeKey;
|
|
1528
|
+
victim.grantedGlobal = bytes;
|
|
1529
|
+
victim.grantedScope = sameScope ? bytes : 0;
|
|
1530
|
+
global += bytes;
|
|
1531
|
+
if (sameScope) scope += bytes;
|
|
1532
|
+
}
|
|
1533
|
+
return { global, scope };
|
|
1534
|
+
},
|
|
1535
|
+
commit(scopeKey) {
|
|
1536
|
+
if (settled) return true;
|
|
1537
|
+
const owned = [];
|
|
1538
|
+
const spared = [];
|
|
1539
|
+
for (const victim of planned) {
|
|
1540
|
+
const entry = executions.get(victim.key);
|
|
1541
|
+
if (entry === void 0) {
|
|
1542
|
+
spared.push(victim);
|
|
1543
|
+
continue;
|
|
1544
|
+
}
|
|
1545
|
+
if (entry.reservation !== token || entry.pending || entry.waiters > 0) spared.push(victim);
|
|
1546
|
+
else owned.push(victim.key);
|
|
1547
|
+
}
|
|
1548
|
+
let owedCount = 0;
|
|
1549
|
+
let owedScopeCount = 0;
|
|
1550
|
+
let owedGlobalBytes = 0;
|
|
1551
|
+
let owedScopeBytes = 0;
|
|
1552
|
+
for (const victim of spared) {
|
|
1553
|
+
owedCount += 1;
|
|
1554
|
+
owedGlobalBytes += victim.grantedGlobal;
|
|
1555
|
+
if (victim.sameScope) {
|
|
1556
|
+
owedScopeCount += 1;
|
|
1557
|
+
owedScopeBytes += victim.grantedScope;
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
const excluded = planned.map((victim) => victim.key);
|
|
1561
|
+
const replacements = [];
|
|
1562
|
+
const bound = executions.size;
|
|
1563
|
+
for (let attempt = 0; attempt < bound; attempt += 1) {
|
|
1564
|
+
if (owedCount <= 0 && owedScopeCount <= 0 && owedGlobalBytes <= 0 && owedScopeBytes <= 0) break;
|
|
1565
|
+
const needScope = owedScopeCount > 0 || owedScopeBytes > 0;
|
|
1566
|
+
const candidate = planReclaim(executions, [...excluded, ...replacements], needScope ? scopeKey : void 0);
|
|
1567
|
+
if (candidate === void 0) {
|
|
1568
|
+
if (needScope) break;
|
|
1569
|
+
break;
|
|
1570
|
+
}
|
|
1571
|
+
replacements.push(candidate);
|
|
1572
|
+
const bytes = stagedBytesOf(storage, candidate);
|
|
1573
|
+
owedCount -= 1;
|
|
1574
|
+
owedGlobalBytes -= bytes;
|
|
1575
|
+
if (executions.get(candidate)?.scopeKey === scopeKey) {
|
|
1576
|
+
owedScopeCount -= 1;
|
|
1577
|
+
owedScopeBytes -= bytes;
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
settled = true;
|
|
1581
|
+
if (owedCount > 0 || owedScopeCount > 0 || owedGlobalBytes > 0 || owedScopeBytes > 0) {
|
|
1582
|
+
for (const key of owned) {
|
|
1583
|
+
const entry = executions.get(key);
|
|
1584
|
+
if (entry?.reservation === token) entry.reservation = void 0;
|
|
1585
|
+
}
|
|
1586
|
+
planned.length = 0;
|
|
1587
|
+
return false;
|
|
1588
|
+
}
|
|
1589
|
+
for (const key of owned) {
|
|
1590
|
+
const entry = executions.get(key);
|
|
1591
|
+
if (entry?.reservation === token) entry.reservation = void 0;
|
|
1592
|
+
commitReclaim(executions, storage, key);
|
|
1593
|
+
}
|
|
1594
|
+
for (const key of replacements) commitReclaim(executions, storage, key);
|
|
1595
|
+
planned.length = 0;
|
|
1596
|
+
return true;
|
|
1597
|
+
},
|
|
1598
|
+
release() {
|
|
1599
|
+
if (settled) return;
|
|
1600
|
+
settled = true;
|
|
1601
|
+
for (const victim of planned) {
|
|
1602
|
+
const entry = executions.get(victim.key);
|
|
1603
|
+
if (entry?.reservation === token) entry.reservation = void 0;
|
|
1604
|
+
}
|
|
1605
|
+
planned.length = 0;
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
610
1609
|
function sourceLocalMidnightDate(instant, timeZone) {
|
|
611
1610
|
const date = new Date(instant);
|
|
612
1611
|
const parts = Object.fromEntries(
|
|
@@ -627,12 +1626,13 @@ function sourceLocalMidnightDate(instant, timeZone) {
|
|
|
627
1626
|
return `${parts.year}-${parts.month}-${parts.day}`;
|
|
628
1627
|
}
|
|
629
1628
|
function deliveryPeriodBoundaryMatches(actual, wireDate, instant) {
|
|
1629
|
+
if (typeof actual !== "string") return false;
|
|
630
1630
|
return actual === wireDate || Date.parse(actual) === Date.parse(instant);
|
|
631
1631
|
}
|
|
632
1632
|
function normalizeDeliveryInstant(value, deliveryDates, period) {
|
|
633
1633
|
if (value === deliveryDates.start) return period.start;
|
|
634
1634
|
if (value === deliveryDates.end) return period.end;
|
|
635
|
-
return value;
|
|
1635
|
+
return typeof value === "string" ? value : String(value);
|
|
636
1636
|
}
|
|
637
1637
|
function scheduleDeadline(deadlineAt, expire) {
|
|
638
1638
|
let timer;
|
|
@@ -656,7 +1656,10 @@ function jsonEvidenceUpperBound(value) {
|
|
|
656
1656
|
return typeof value === "number" ? 32 : Math.min(Number.MAX_SAFE_INTEGER, Buffer.byteLength(value, "utf8") * 6 + 2);
|
|
657
1657
|
}
|
|
658
1658
|
export {
|
|
1659
|
+
INLINE_REPORTING_AVAILABILITY_EVIDENCE_VERSION_V1,
|
|
659
1660
|
InlineReportingSourceError,
|
|
660
1661
|
ReportingSourceNotReadyError,
|
|
661
|
-
createInlineReportingSourceExecutor
|
|
1662
|
+
createInlineReportingSourceExecutor,
|
|
1663
|
+
createInlineReportingSourceExecutorForTestsV1,
|
|
1664
|
+
inlineStagingCapacitiesForTestsV1
|
|
662
1665
|
};
|