@adcp/sdk 14.0.0-beta.12 → 14.0.0-beta.13

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.
Files changed (175) hide show
  1. package/dist/lib/index.d.mts +3 -3
  2. package/dist/lib/index.d.ts +3 -3
  3. package/dist/lib/index.d.ts.map +1 -1
  4. package/dist/lib/index.js +2 -0
  5. package/dist/lib/index.js.map +1 -1
  6. package/dist/lib/index.mjs +3 -1
  7. package/dist/lib/index.mjs.map +1 -1
  8. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  9. package/dist/lib/server/create-adcp-server.d.mts +2 -2
  10. package/dist/lib/server/create-adcp-server.d.ts +2 -2
  11. package/dist/lib/server/create-adcp-server.d.ts.map +1 -1
  12. package/dist/lib/server/create-adcp-server.js +6 -1
  13. package/dist/lib/server/create-adcp-server.js.map +1 -1
  14. package/dist/lib/server/create-adcp-server.mjs +6 -1
  15. package/dist/lib/server/create-adcp-server.mjs.map +1 -1
  16. package/dist/lib/server/decisioning/index.d.mts +3 -3
  17. package/dist/lib/server/decisioning/index.d.ts +3 -3
  18. package/dist/lib/server/decisioning/index.d.ts.map +1 -1
  19. package/dist/lib/server/decisioning/index.js.map +1 -1
  20. package/dist/lib/server/decisioning/index.mjs.map +1 -1
  21. package/dist/lib/server/decisioning/runtime/from-platform.d.mts +24 -17
  22. package/dist/lib/server/decisioning/runtime/from-platform.d.ts +24 -17
  23. package/dist/lib/server/decisioning/runtime/from-platform.d.ts.map +1 -1
  24. package/dist/lib/server/decisioning/runtime/from-platform.js +71 -42
  25. package/dist/lib/server/decisioning/runtime/from-platform.js.map +1 -1
  26. package/dist/lib/server/decisioning/runtime/from-platform.mjs +75 -43
  27. package/dist/lib/server/decisioning/runtime/from-platform.mjs.map +1 -1
  28. package/dist/lib/server/decisioning/runtime/postgres-task-registry.d.mts +15 -21
  29. package/dist/lib/server/decisioning/runtime/postgres-task-registry.d.ts +15 -21
  30. package/dist/lib/server/decisioning/runtime/postgres-task-registry.d.ts.map +1 -1
  31. package/dist/lib/server/decisioning/runtime/postgres-task-registry.js +100 -30
  32. package/dist/lib/server/decisioning/runtime/postgres-task-registry.js.map +1 -1
  33. package/dist/lib/server/decisioning/runtime/postgres-task-registry.mjs +100 -30
  34. package/dist/lib/server/decisioning/runtime/postgres-task-registry.mjs.map +1 -1
  35. package/dist/lib/server/decisioning/runtime/task-registry.d.mts +30 -16
  36. package/dist/lib/server/decisioning/runtime/task-registry.d.ts +30 -16
  37. package/dist/lib/server/decisioning/runtime/task-registry.d.ts.map +1 -1
  38. package/dist/lib/server/decisioning/runtime/task-registry.js +40 -20
  39. package/dist/lib/server/decisioning/runtime/task-registry.js.map +1 -1
  40. package/dist/lib/server/decisioning/runtime/task-registry.mjs +38 -19
  41. package/dist/lib/server/decisioning/runtime/task-registry.mjs.map +1 -1
  42. package/dist/lib/server/decisioning/runtime/to-context.d.mts +2 -2
  43. package/dist/lib/server/decisioning/runtime/to-context.d.ts +2 -2
  44. package/dist/lib/server/decisioning/runtime/to-context.d.ts.map +1 -1
  45. package/dist/lib/server/decisioning/runtime/to-context.js +2 -2
  46. package/dist/lib/server/decisioning/runtime/to-context.js.map +1 -1
  47. package/dist/lib/server/decisioning/runtime/to-context.mjs +2 -2
  48. package/dist/lib/server/decisioning/runtime/to-context.mjs.map +1 -1
  49. package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.mts +3 -2
  50. package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts +3 -2
  51. package/dist/lib/server/decisioning/specialisms/creative-ad-server.d.ts.map +1 -1
  52. package/dist/lib/server/decisioning/specialisms/creative-ad-server.js.map +1 -1
  53. package/dist/lib/server/decisioning/specialisms/creative.d.mts +10 -10
  54. package/dist/lib/server/decisioning/specialisms/creative.d.ts +10 -10
  55. package/dist/lib/server/decisioning/specialisms/creative.d.ts.map +1 -1
  56. package/dist/lib/server/decisioning/specialisms/creative.js.map +1 -1
  57. package/dist/lib/server/index.d.mts +1 -1
  58. package/dist/lib/server/index.d.ts +1 -1
  59. package/dist/lib/server/index.d.ts.map +1 -1
  60. package/dist/lib/server/index.js.map +1 -1
  61. package/dist/lib/server/index.mjs.map +1 -1
  62. package/dist/lib/testing/storyboard/default-invariants.d.ts.map +1 -1
  63. package/dist/lib/testing/storyboard/default-invariants.js +11 -2
  64. package/dist/lib/testing/storyboard/default-invariants.js.map +1 -1
  65. package/dist/lib/testing/storyboard/default-invariants.mjs +11 -2
  66. package/dist/lib/testing/storyboard/default-invariants.mjs.map +1 -1
  67. package/dist/lib/testing/storyboard/index.d.mts +1 -1
  68. package/dist/lib/testing/storyboard/index.d.ts +1 -1
  69. package/dist/lib/testing/storyboard/index.d.ts.map +1 -1
  70. package/dist/lib/testing/storyboard/index.js.map +1 -1
  71. package/dist/lib/testing/storyboard/index.mjs.map +1 -1
  72. package/dist/lib/testing/storyboard/loader.d.ts.map +1 -1
  73. package/dist/lib/testing/storyboard/loader.js +14 -0
  74. package/dist/lib/testing/storyboard/loader.js.map +1 -1
  75. package/dist/lib/testing/storyboard/loader.mjs +14 -0
  76. package/dist/lib/testing/storyboard/loader.mjs.map +1 -1
  77. package/dist/lib/testing/storyboard/phase-condition.d.mts +41 -0
  78. package/dist/lib/testing/storyboard/phase-condition.d.ts +42 -0
  79. package/dist/lib/testing/storyboard/phase-condition.d.ts.map +1 -0
  80. package/dist/lib/testing/storyboard/phase-condition.js +215 -0
  81. package/dist/lib/testing/storyboard/phase-condition.js.map +1 -0
  82. package/dist/lib/testing/storyboard/phase-condition.mjs +189 -0
  83. package/dist/lib/testing/storyboard/phase-condition.mjs.map +1 -0
  84. package/dist/lib/testing/storyboard/request-builder.d.ts.map +1 -1
  85. package/dist/lib/testing/storyboard/request-builder.js +15 -2
  86. package/dist/lib/testing/storyboard/request-builder.js.map +1 -1
  87. package/dist/lib/testing/storyboard/request-builder.mjs +15 -2
  88. package/dist/lib/testing/storyboard/request-builder.mjs.map +1 -1
  89. package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
  90. package/dist/lib/testing/storyboard/runner.js +57 -23
  91. package/dist/lib/testing/storyboard/runner.js.map +1 -1
  92. package/dist/lib/testing/storyboard/runner.mjs +57 -23
  93. package/dist/lib/testing/storyboard/runner.mjs.map +1 -1
  94. package/dist/lib/testing/storyboard/task-map.d.ts.map +1 -1
  95. package/dist/lib/testing/storyboard/task-map.js +6 -2
  96. package/dist/lib/testing/storyboard/task-map.js.map +1 -1
  97. package/dist/lib/testing/storyboard/task-map.mjs +6 -2
  98. package/dist/lib/testing/storyboard/task-map.mjs.map +1 -1
  99. package/dist/lib/testing/storyboard/types.d.mts +5 -4
  100. package/dist/lib/testing/storyboard/types.d.ts +5 -4
  101. package/dist/lib/testing/storyboard/types.d.ts.map +1 -1
  102. package/dist/lib/testing/storyboard/types.js.map +1 -1
  103. package/dist/lib/testing/storyboard/types.mjs.map +1 -1
  104. package/dist/lib/testing/storyboard/validations.d.mts +1 -1
  105. package/dist/lib/testing/storyboard/validations.d.ts +1 -1
  106. package/dist/lib/testing/storyboard/webhook-assertions.d.ts.map +1 -1
  107. package/dist/lib/testing/storyboard/webhook-assertions.js +60 -4
  108. package/dist/lib/testing/storyboard/webhook-assertions.js.map +1 -1
  109. package/dist/lib/testing/storyboard/webhook-assertions.mjs +60 -4
  110. package/dist/lib/testing/storyboard/webhook-assertions.mjs.map +1 -1
  111. package/dist/lib/testing/storyboard/webhook-receiver.d.mts +15 -0
  112. package/dist/lib/testing/storyboard/webhook-receiver.d.ts +15 -0
  113. package/dist/lib/testing/storyboard/webhook-receiver.d.ts.map +1 -1
  114. package/dist/lib/testing/storyboard/webhook-receiver.js +57 -6
  115. package/dist/lib/testing/storyboard/webhook-receiver.js.map +1 -1
  116. package/dist/lib/testing/storyboard/webhook-receiver.mjs +57 -6
  117. package/dist/lib/testing/storyboard/webhook-receiver.mjs.map +1 -1
  118. package/dist/lib/testing/types.d.mts +2 -0
  119. package/dist/lib/testing/types.d.ts +2 -0
  120. package/dist/lib/testing/types.d.ts.map +1 -1
  121. package/dist/lib/testing/types.js.map +1 -1
  122. package/dist/lib/types/core.generated.d.mts +5 -2
  123. package/dist/lib/types/core.generated.d.ts +5 -2
  124. package/dist/lib/types/core.generated.d.ts.map +1 -1
  125. package/dist/lib/types/core.generated.js.map +1 -1
  126. package/dist/lib/types/index.d.mts +1 -1
  127. package/dist/lib/types/index.d.ts +1 -1
  128. package/dist/lib/types/index.d.ts.map +1 -1
  129. package/dist/lib/types/index.js.map +1 -1
  130. package/dist/lib/types/index.mjs.map +1 -1
  131. package/dist/lib/types/list-transformers.d.ts +9 -5
  132. package/dist/lib/types/schemas.generated.d.ts +21 -298
  133. package/dist/lib/types/schemas.generated.d.ts.map +1 -1
  134. package/dist/lib/types/schemas.generated.js +5 -2
  135. package/dist/lib/types/schemas.generated.js.map +1 -1
  136. package/dist/lib/types/schemas.generated.mjs +4 -2
  137. package/dist/lib/types/schemas.generated.mjs.map +1 -1
  138. package/dist/lib/types/server-payload-aliases.d.mts +2 -1
  139. package/dist/lib/types/server-payload-aliases.d.ts +2 -1
  140. package/dist/lib/types/server-payload-aliases.d.ts.map +1 -1
  141. package/dist/lib/types/server-payload-aliases.js.map +1 -1
  142. package/dist/lib/types/tools.generated.d.mts +5 -2
  143. package/dist/lib/types/tools.generated.d.ts +5 -2
  144. package/dist/lib/types/tools.generated.d.ts.map +1 -1
  145. package/dist/lib/types/tools.generated.js.map +1 -1
  146. package/dist/lib/utils/build-creative-return-builders.d.mts +5 -1
  147. package/dist/lib/utils/build-creative-return-builders.d.ts +5 -1
  148. package/dist/lib/utils/build-creative-return-builders.d.ts.map +1 -1
  149. package/dist/lib/utils/build-creative-return-builders.js +9 -3
  150. package/dist/lib/utils/build-creative-return-builders.js.map +1 -1
  151. package/dist/lib/utils/build-creative-return-builders.mjs +7 -2
  152. package/dist/lib/utils/build-creative-return-builders.mjs.map +1 -1
  153. package/dist/lib/utils/response-unwrapper.js +1 -1
  154. package/dist/lib/utils/response-unwrapper.js.map +1 -1
  155. package/dist/lib/utils/response-unwrapper.mjs +1 -1
  156. package/dist/lib/utils/response-unwrapper.mjs.map +1 -1
  157. package/dist/lib/validation/schema-loader.d.ts.map +1 -1
  158. package/dist/lib/validation/schema-loader.js +16 -7
  159. package/dist/lib/validation/schema-loader.js.map +1 -1
  160. package/dist/lib/validation/schema-loader.mjs +16 -7
  161. package/dist/lib/validation/schema-loader.mjs.map +1 -1
  162. package/dist/lib/version.d.mts +3 -3
  163. package/dist/lib/version.d.ts +3 -3
  164. package/dist/lib/version.js +3 -3
  165. package/dist/lib/version.js.map +1 -1
  166. package/dist/lib/version.mjs +3 -3
  167. package/dist/lib/version.mjs.map +1 -1
  168. package/docs/llms.txt +2 -2
  169. package/docs/migration-5.x-to-6.x.md +3 -2
  170. package/docs/migration-task-registry-scoping.md +61 -0
  171. package/examples/hello_seller_adapter_guaranteed.ts +1 -1
  172. package/package.json +4 -4
  173. package/skills/build-decisioning-creative-template/SKILL.md +2 -2
  174. package/skills/build-decisioning-platform/SKILL.md +4 -2
  175. package/skills/build-decisioning-platform/advanced/REFERENCE.md +7 -6
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/testing/storyboard/index.ts"],"sourcesContent":["/**\n * Storyboard-driven testing for AdCP agents.\n *\n * Storyboards are YAML-defined workflows that map directly to\n * SingleAgentClient methods, enabling step-by-step agent testing.\n * The canonical storyboard set lives in the AdCP compliance tarball\n * and is pulled into `compliance/cache/{version}/` via `npm run sync-schemas`.\n */\n\n// Side-effect import: registers the default cross-step assertions that\n// upstream storyboards reference by id (idempotency.conflict_no_payload_leak,\n// context.no_secret_echo, governance.denial_blocks_mutation). Without this\n// registration here, any `runStoryboard` call against a storyboard declaring\n// `invariants: [...]` would throw at start on unresolved ids. Consumers who\n// want to replace the defaults can `clearAssertionRegistry()` first.\nimport { registerDefaultInvariants } from './default-invariants';\n\nregisterDefaultInvariants();\n\n// Types\nexport type {\n A2ATaskEnvelope,\n AgentEntry,\n Storyboard,\n StoryboardFixtureResolution,\n FixtureResolutionStrategy,\n FixtureMatchOperator,\n FixtureMatchClause,\n FixtureResolutionDeclaration,\n ProductFixtureResolutionDeclaration,\n PricingOptionFixtureResolutionDeclaration,\n FixtureResolutionStatus,\n FixtureResolutionRecord,\n FixtureResolutionAttempt,\n FixtureResolutionEvidence,\n FixtureResolutionCoverageGap,\n StoryboardInvariants,\n StoryboardInvariantsObject,\n StepInvariantsObject,\n StoryboardPhase,\n StoryboardStep,\n RateLimitTripSpec,\n StoryboardValidation,\n StoryboardValidationCheck,\n WebhookFilterSpec,\n WebhookRetryTriggerSpec,\n WebhookAssertionErrorCode,\n ContextOutput,\n ContextInput,\n ContextProvenanceEntry,\n ContextValueRejectedHint,\n ShapeDriftHint,\n MissingRequiredFieldHint,\n FormatMismatchHint,\n MonotonicViolationHint,\n ImpairmentCoherenceHint,\n ImpairmentCoherenceNotApplicableHint,\n StoryboardContext,\n StoryboardRunOptions,\n TrustedMatchContextProviderEndpoint,\n TrustedMatchContextRegistrationContext,\n TrustedMatchContextRouterRunnerOptions,\n TrustedMatchPublisherAuthOperation,\n TrustedMatchPublisherCredentialState,\n TrustedMatchPublisherAuthTls,\n TrustedMatchPublisherAuthProbeConfiguration,\n TrustedMatchPublisherAuthRunner,\n ValidationResult,\n StoryboardStepPreview,\n StoryboardStepResult,\n StoryboardStepHint,\n StoryboardStepHintBase,\n StoryboardPhaseResult,\n StoryboardResult,\n AssertionResult,\n StrictValidationSummary,\n StrictValidationVerdict,\n UpstreamTrafficPayloadMatch,\n RunnerNotice,\n NoticeCode,\n NoticeSeverity,\n} from './types';\nexport { WEBHOOK_IDEMPOTENCY_KEY_PATTERN } from './types';\n\n// Cross-step assertion registry (adcontextprotocol/adcp#2639)\nexport {\n registerAssertion,\n getAssertion,\n listAssertions,\n listDefaultAssertions,\n clearAssertionRegistry,\n resolveAssertions,\n} from './assertions';\nexport type { AssertionSpec, AssertionContext, RegisterAssertionOptions } from './assertions';\n\n// Webhook receiver (outbound-webhook conformance testing per adcontextprotocol/adcp#2431)\nexport { createWebhookReceiver } from './webhook-receiver';\nexport type {\n CapturedWebhook,\n CreateWebhookReceiverOptions,\n RetryReplayPolicy,\n WebhookFilter,\n WebhookReceiver,\n WebhookWaitResult,\n} from './webhook-receiver';\n\n// Runner-variable substitution (`{{runner.*}}` / `{{prior_step.*.operation_id}}`)\nexport { createRunnerVariables } from './context';\nexport type { RunnerVariables } from './context';\n\n// Webhook-assertion pseudo-tasks\nexport { WEBHOOK_ASSERTION_TASKS } from './webhook-assertions';\n\n// Runner\nexport {\n runStoryboard,\n runStoryboardStep,\n applyAdcpVersionRunOptions,\n applyStoryboardVersionOptions,\n getFirstStepPreview,\n summarizeStrictValidation,\n listStrictOnlyFailures,\n resolveCapabilityPath,\n evaluateCapabilityPredicate,\n describeStoryboardCapabilityGates,\n buildDiscoveryFailedResult,\n} from './runner';\n\n// Parser (single-file load for spec evolution / targeted testing)\nexport { parseStoryboard, loadStoryboardFile } from './loader';\n\n// AdCP 3.2 fixture-handle resolution\nexport {\n applyFixtureBindingsToRequest,\n buildFixtureResolutionSpecs,\n FixtureBindingRegistry,\n matchesFixtureRequirements,\n normalizeFixtureMatchExpression,\n validateFixtureResolutionDeclarations,\n} from './fixture-resolution';\n\n// Compliance cache: capability-driven resolution\nexport {\n getComplianceCacheDir,\n getExternalSchemaRootForCompliance,\n loadComplianceIndex,\n listBundles,\n loadBundleStoryboards,\n listAllComplianceStoryboards,\n getComplianceStoryboardById,\n findBundleById,\n resolveBundleOrStoryboard,\n resolveStoryboardsForCapabilities,\n isComplianceVersionSupported,\n loadSpecialismDetail,\n listSpecialisms,\n CapabilityResolutionError,\n PROTOCOL_TO_PATH,\n UNBASELINED_SUPPORTED_PROTOCOLS,\n} from './compliance';\nexport type {\n AgentCapabilities,\n BundleKind,\n BundleRef,\n CapabilityResolutionCode,\n ComplianceIndex,\n ComplianceIndexProtocol,\n ComplianceIndexSpecialism,\n NotApplicableStoryboard,\n ResolveOptions,\n ResolvedBundle,\n ResolvedStoryboards,\n SpecialismDetail,\n} from './compliance';\n\n// Task mapping\nexport { TASK_TO_METHOD, executeStoryboardTask } from './task-map';\n\n// Storyboard-only creative asset directives\nexport { expandCreativeAssetDirectives, findUnresolvedCreativeAssetDirectives } from './creative-assets';\n\n// Path utilities\nexport { parsePath, resolvePath, setPath } from './path';\n\n// Context\nexport {\n CONTEXT_EXTRACTORS,\n extractContext,\n extractContextWithProvenance,\n injectContext,\n applyContextOutputs,\n applyContextOutputsWithProvenance,\n applyContextInputs,\n} from './context';\nexport type { ContextWriteResult } from './context';\n\n// Rejection-hint detection (issue #870)\nexport { detectContextRejectionHints } from './rejection-hints';\n\n// Request builder\nexport { buildRequest, hasRequestBuilder } from './request-builder';\n\n// Validations\nexport { runValidations } from './validations';\nexport {\n gradeOAuthMetadataGraph,\n gradeOAuthMetadataGraphVector,\n loadOAuthMetadataGraphVectors,\n buildAuthorizationServerMetadataUrl,\n buildProtectedResourceMetadataUrl,\n normalizeOAuthResourceForComparison,\n redactOAuthUrlForOutput,\n} from './oauth-metadata-graph';\nexport type {\n GradeOAuthMetadataGraphOptions,\n OAuthMetadataFetchResponse,\n OAuthMetadataFetchTransport,\n OAuthMetadataGraphErrorCode,\n OAuthMetadataGraphFinding,\n OAuthMetadataGraphGrade,\n OAuthMetadataGraphObservation,\n OAuthMetadataGraphVector,\n OAuthMetadataGraphVectorCorpus,\n} from './oauth-metadata-graph';\nexport {\n RateLimitTripObserver,\n RATE_LIMIT_TRIP_CONTRACT,\n RATE_LIMIT_TRIP_DEFAULT_REPLAY_MAX_WAIT_SECONDS,\n RATE_LIMIT_TRIP_MAX_ATTEMPTS_MAX,\n RATE_LIMIT_TRIP_MAX_ATTEMPTS_MIN,\n extractTaskAdcpError,\n validateRateLimitTripSpec,\n type RateLimitTripFailureCode,\n type RateLimitTripClient,\n type RateLimitTripObservation,\n type RateLimitTripObserverOptions,\n type RateLimitTripResponseSnapshot,\n type RateLimitTripStructuredResult,\n type RateLimitTripTaskOptions,\n} from './rate-limit-trip';\n\n// `./junit` is deliberately NOT re-exported. The CLI requires it\n// directly from `dist/lib/testing/storyboard/junit.js` and the function\n// is marked `@internal` (stripped from the generated `.d.ts`). Add a\n// re-export here only if/when we promote it to a public API surface.\n\n// Test-kit schema validation\nexport { validateTestKit, TestKitValidationError, PROBE_TASK_ALLOWLIST } from './test-kit';\n\n// Sandbox entities\nexport type { SandboxBrand, SandboxAgent, SandboxEntities, BrandJson } from './sandbox-entities';\nexport { BrandJsonSchema, AdagentsJsonSchema } from '../../types/wellknown-schemas.generated';\nexport type { AdagentsJson } from '../../types/wellknown-schemas.generated';\nexport {\n getSandboxEntities,\n getSandboxBrands,\n getSandboxBrand,\n isSandboxDomain,\n clearSandboxCache,\n} from './sandbox-entities';\n"],"mappings":"AAeA,SAAS,iCAAiC;AAE1C,0BAA0B;AAiE1B,SAAS,uCAAuC;AAGhD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIP,SAAS,6BAA6B;AAWtC,SAAS,6BAA6B;AAItC,SAAS,+BAA+B;AAGxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,iBAAiB,0BAA0B;AAGpD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAiBP,SAAS,gBAAgB,6BAA6B;AAGtD,SAAS,+BAA+B,6CAA6C;AAGrF,SAAS,WAAW,aAAa,eAAe;AAGhD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIP,SAAS,mCAAmC;AAG5C,SAAS,cAAc,yBAAyB;AAGhD,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAYP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAQK;AAQP,SAAS,iBAAiB,wBAAwB,4BAA4B;AAI9E,SAAS,iBAAiB,0BAA0B;AAEpD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
1
+ {"version":3,"sources":["../../../../src/lib/testing/storyboard/index.ts"],"sourcesContent":["/**\n * Storyboard-driven testing for AdCP agents.\n *\n * Storyboards are YAML-defined workflows that map directly to\n * SingleAgentClient methods, enabling step-by-step agent testing.\n * The canonical storyboard set lives in the AdCP compliance tarball\n * and is pulled into `compliance/cache/{version}/` via `npm run sync-schemas`.\n */\n\n// Side-effect import: registers the default cross-step assertions that\n// upstream storyboards reference by id (idempotency.conflict_no_payload_leak,\n// context.no_secret_echo, governance.denial_blocks_mutation). Without this\n// registration here, any `runStoryboard` call against a storyboard declaring\n// `invariants: [...]` would throw at start on unresolved ids. Consumers who\n// want to replace the defaults can `clearAssertionRegistry()` first.\nimport { registerDefaultInvariants } from './default-invariants';\n\nregisterDefaultInvariants();\n\n// Types\nexport type {\n A2ATaskEnvelope,\n AgentEntry,\n Storyboard,\n StoryboardFixtureResolution,\n FixtureResolutionStrategy,\n FixtureMatchOperator,\n FixtureMatchClause,\n FixtureResolutionDeclaration,\n ProductFixtureResolutionDeclaration,\n PricingOptionFixtureResolutionDeclaration,\n FixtureResolutionStatus,\n FixtureResolutionRecord,\n FixtureResolutionAttempt,\n FixtureResolutionEvidence,\n FixtureResolutionCoverageGap,\n StoryboardInvariants,\n StoryboardInvariantsObject,\n StepInvariantsObject,\n StoryboardPhase,\n StoryboardStep,\n RateLimitTripSpec,\n StoryboardValidation,\n StoryboardValidationCheck,\n WebhookFilterSpec,\n WebhookRetryTriggerSpec,\n WebhookAssertionErrorCode,\n ContextOutput,\n ContextInput,\n ContextProvenanceEntry,\n ContextValueRejectedHint,\n ShapeDriftHint,\n MissingRequiredFieldHint,\n FormatMismatchHint,\n MonotonicViolationHint,\n ImpairmentCoherenceHint,\n ImpairmentCoherenceNotApplicableHint,\n StoryboardContext,\n StoryboardRunOptions,\n TrustedMatchContextProviderEndpoint,\n TrustedMatchContextRegistrationContext,\n TrustedMatchContextRouterRunnerOptions,\n TrustedMatchPublisherAuthOperation,\n TrustedMatchPublisherCredentialState,\n TrustedMatchPublisherAuthTls,\n TrustedMatchPublisherAuthProbeConfiguration,\n TrustedMatchPublisherAuthRunner,\n ValidationResult,\n StoryboardStepPreview,\n StoryboardStepResult,\n StoryboardStepHint,\n StoryboardStepHintBase,\n StoryboardPhaseResult,\n StoryboardResult,\n AssertionResult,\n StrictValidationSummary,\n StrictValidationVerdict,\n UpstreamTrafficPayloadMatch,\n RunnerNotice,\n NoticeCode,\n NoticeSeverity,\n} from './types';\nexport { WEBHOOK_IDEMPOTENCY_KEY_PATTERN } from './types';\n\n// Cross-step assertion registry (adcontextprotocol/adcp#2639)\nexport {\n registerAssertion,\n getAssertion,\n listAssertions,\n listDefaultAssertions,\n clearAssertionRegistry,\n resolveAssertions,\n} from './assertions';\nexport type { AssertionSpec, AssertionContext, RegisterAssertionOptions } from './assertions';\n\n// Webhook receiver (outbound-webhook conformance testing per adcontextprotocol/adcp#2431)\nexport { createWebhookReceiver } from './webhook-receiver';\nexport type {\n CapturedWebhook,\n CapturedWebhookChallenge,\n CreateWebhookReceiverOptions,\n RetryReplayPolicy,\n WebhookFilter,\n WebhookReceiver,\n WebhookWaitResult,\n} from './webhook-receiver';\n\n// Runner-variable substitution (`{{runner.*}}` / `{{prior_step.*.operation_id}}`)\nexport { createRunnerVariables } from './context';\nexport type { RunnerVariables } from './context';\n\n// Webhook-assertion pseudo-tasks\nexport { WEBHOOK_ASSERTION_TASKS } from './webhook-assertions';\n\n// Runner\nexport {\n runStoryboard,\n runStoryboardStep,\n applyAdcpVersionRunOptions,\n applyStoryboardVersionOptions,\n getFirstStepPreview,\n summarizeStrictValidation,\n listStrictOnlyFailures,\n resolveCapabilityPath,\n evaluateCapabilityPredicate,\n describeStoryboardCapabilityGates,\n buildDiscoveryFailedResult,\n} from './runner';\n\n// Parser (single-file load for spec evolution / targeted testing)\nexport { parseStoryboard, loadStoryboardFile } from './loader';\n\n// AdCP 3.2 fixture-handle resolution\nexport {\n applyFixtureBindingsToRequest,\n buildFixtureResolutionSpecs,\n FixtureBindingRegistry,\n matchesFixtureRequirements,\n normalizeFixtureMatchExpression,\n validateFixtureResolutionDeclarations,\n} from './fixture-resolution';\n\n// Compliance cache: capability-driven resolution\nexport {\n getComplianceCacheDir,\n getExternalSchemaRootForCompliance,\n loadComplianceIndex,\n listBundles,\n loadBundleStoryboards,\n listAllComplianceStoryboards,\n getComplianceStoryboardById,\n findBundleById,\n resolveBundleOrStoryboard,\n resolveStoryboardsForCapabilities,\n isComplianceVersionSupported,\n loadSpecialismDetail,\n listSpecialisms,\n CapabilityResolutionError,\n PROTOCOL_TO_PATH,\n UNBASELINED_SUPPORTED_PROTOCOLS,\n} from './compliance';\nexport type {\n AgentCapabilities,\n BundleKind,\n BundleRef,\n CapabilityResolutionCode,\n ComplianceIndex,\n ComplianceIndexProtocol,\n ComplianceIndexSpecialism,\n NotApplicableStoryboard,\n ResolveOptions,\n ResolvedBundle,\n ResolvedStoryboards,\n SpecialismDetail,\n} from './compliance';\n\n// Task mapping\nexport { TASK_TO_METHOD, executeStoryboardTask } from './task-map';\n\n// Storyboard-only creative asset directives\nexport { expandCreativeAssetDirectives, findUnresolvedCreativeAssetDirectives } from './creative-assets';\n\n// Path utilities\nexport { parsePath, resolvePath, setPath } from './path';\n\n// Context\nexport {\n CONTEXT_EXTRACTORS,\n extractContext,\n extractContextWithProvenance,\n injectContext,\n applyContextOutputs,\n applyContextOutputsWithProvenance,\n applyContextInputs,\n} from './context';\nexport type { ContextWriteResult } from './context';\n\n// Rejection-hint detection (issue #870)\nexport { detectContextRejectionHints } from './rejection-hints';\n\n// Request builder\nexport { buildRequest, hasRequestBuilder } from './request-builder';\n\n// Validations\nexport { runValidations } from './validations';\nexport {\n gradeOAuthMetadataGraph,\n gradeOAuthMetadataGraphVector,\n loadOAuthMetadataGraphVectors,\n buildAuthorizationServerMetadataUrl,\n buildProtectedResourceMetadataUrl,\n normalizeOAuthResourceForComparison,\n redactOAuthUrlForOutput,\n} from './oauth-metadata-graph';\nexport type {\n GradeOAuthMetadataGraphOptions,\n OAuthMetadataFetchResponse,\n OAuthMetadataFetchTransport,\n OAuthMetadataGraphErrorCode,\n OAuthMetadataGraphFinding,\n OAuthMetadataGraphGrade,\n OAuthMetadataGraphObservation,\n OAuthMetadataGraphVector,\n OAuthMetadataGraphVectorCorpus,\n} from './oauth-metadata-graph';\nexport {\n RateLimitTripObserver,\n RATE_LIMIT_TRIP_CONTRACT,\n RATE_LIMIT_TRIP_DEFAULT_REPLAY_MAX_WAIT_SECONDS,\n RATE_LIMIT_TRIP_MAX_ATTEMPTS_MAX,\n RATE_LIMIT_TRIP_MAX_ATTEMPTS_MIN,\n extractTaskAdcpError,\n validateRateLimitTripSpec,\n type RateLimitTripFailureCode,\n type RateLimitTripClient,\n type RateLimitTripObservation,\n type RateLimitTripObserverOptions,\n type RateLimitTripResponseSnapshot,\n type RateLimitTripStructuredResult,\n type RateLimitTripTaskOptions,\n} from './rate-limit-trip';\n\n// `./junit` is deliberately NOT re-exported. The CLI requires it\n// directly from `dist/lib/testing/storyboard/junit.js` and the function\n// is marked `@internal` (stripped from the generated `.d.ts`). Add a\n// re-export here only if/when we promote it to a public API surface.\n\n// Test-kit schema validation\nexport { validateTestKit, TestKitValidationError, PROBE_TASK_ALLOWLIST } from './test-kit';\n\n// Sandbox entities\nexport type { SandboxBrand, SandboxAgent, SandboxEntities, BrandJson } from './sandbox-entities';\nexport { BrandJsonSchema, AdagentsJsonSchema } from '../../types/wellknown-schemas.generated';\nexport type { AdagentsJson } from '../../types/wellknown-schemas.generated';\nexport {\n getSandboxEntities,\n getSandboxBrands,\n getSandboxBrand,\n isSandboxDomain,\n clearSandboxCache,\n} from './sandbox-entities';\n"],"mappings":"AAeA,SAAS,iCAAiC;AAE1C,0BAA0B;AAiE1B,SAAS,uCAAuC;AAGhD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIP,SAAS,6BAA6B;AAYtC,SAAS,6BAA6B;AAItC,SAAS,+BAA+B;AAGxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,iBAAiB,0BAA0B;AAGpD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAiBP,SAAS,gBAAgB,6BAA6B;AAGtD,SAAS,+BAA+B,6CAA6C;AAGrF,SAAS,WAAW,aAAa,eAAe;AAGhD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIP,SAAS,mCAAmC;AAG5C,SAAS,cAAc,yBAAyB;AAGhD,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAYP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAQK;AAQP,SAAS,iBAAiB,wBAAwB,4BAA4B;AAI9E,SAAS,iBAAiB,0BAA0B;AAEpD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../src/lib/testing/storyboard/loader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,qBAAsB,CAAC;AAMxD,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU,CA4B/D;AAED,kGAAkG;AAClG,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAE/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAoBpE"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../src/lib/testing/storyboard/loader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAM1C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,qBAAsB,CAAC;AAMxD,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU,CA4B/D;AAED,kGAAkG;AAClG,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAE/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAqBpE"}
@@ -29,6 +29,7 @@ var import_yaml = require("yaml");
29
29
  var import_idempotency = require('../../utils/idempotency.js');
30
30
  var import_fixture_resolution = require('./fixture-resolution.js');
31
31
  var import_semver = require("semver");
32
+ var import_phase_condition = require('./phase-condition.js');
32
33
  const BRANCH_SET_SEMANTICS = ["any_of"];
33
34
  const IDENTIFIER_PATH_SEGMENT = String.raw`[A-Za-z_][A-Za-z0-9_-]*(?:\[\*\])*`;
34
35
  const IDENTIFIER_PATH_PATTERN = new RegExp(`^${IDENTIFIER_PATH_SEGMENT}(?:\\.${IDENTIFIER_PATH_SEGMENT})*$`);
@@ -68,6 +69,7 @@ function validateStoryboardShape(storyboard) {
68
69
  validateRequiredAnyOfTools(storyboard);
69
70
  validatePhaseDependsOn(storyboard);
70
71
  for (const phase of storyboard.phases) {
72
+ validatePhaseSkipIf(storyboard.id, phase);
71
73
  validateBranchSet(storyboard.id, phase);
72
74
  if (!phase.steps) continue;
73
75
  for (const step of phase.steps) {
@@ -82,6 +84,18 @@ function validateStoryboardShape(storyboard) {
82
84
  }
83
85
  }
84
86
  }
87
+ function validatePhaseSkipIf(storyboardId, phase) {
88
+ if (phase.skip_if === void 0) return;
89
+ if (typeof phase.skip_if !== "string") {
90
+ throw new Error(`[${storyboardId}] phase '${phase.id}': skip_if must be a string`);
91
+ }
92
+ try {
93
+ (0, import_phase_condition.parsePhaseCondition)(phase.skip_if);
94
+ } catch (error) {
95
+ const detail = error instanceof Error ? error.message : String(error);
96
+ throw new Error(`[${storyboardId}] phase '${phase.id}': ${detail}`);
97
+ }
98
+ }
85
99
  function validateRequiresAllCapabilities(storyboard) {
86
100
  const predicates = storyboard.requires_all_capabilities;
87
101
  if (predicates === void 0) return;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/testing/storyboard/loader.ts"],"sourcesContent":["/**\n * Storyboard YAML parser.\n *\n * Storyboards are pulled from the compliance cache populated by\n * `npm run sync-schemas`. See `./compliance.ts` for capability-driven\n * resolution and bundle loading.\n */\n\nimport { readFileSync } from 'fs';\nimport { parse } from 'yaml';\nimport type { Storyboard } from './types';\nimport { MUTATING_TASKS } from '../../utils/idempotency';\nimport { validateFixtureResolutionDeclarations } from './fixture-resolution';\nimport { valid as validSemver } from 'semver';\n\n/**\n * Supported `branch_set.semantics` values. Extend when AdCP adds `all_of`,\n * `at_least_n`, etc. Exported so the runner can enforce the same whitelist\n * on programmatically-constructed storyboards that bypass the YAML parser.\n */\nexport const BRANCH_SET_SEMANTICS = ['any_of'] as const;\n\nconst IDENTIFIER_PATH_SEGMENT = String.raw`[A-Za-z_][A-Za-z0-9_-]*(?:\\[\\*\\])*`;\nconst IDENTIFIER_PATH_PATTERN = new RegExp(`^${IDENTIFIER_PATH_SEGMENT}(?:\\\\.${IDENTIFIER_PATH_SEGMENT})*$`);\nconst CAPABILITY_PATH_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*(?:\\.[A-Za-z_][A-Za-z0-9_-]*)*$/;\n\n/** Parse a YAML string into a Storyboard. Throws if required fields are missing. */\nexport function parseStoryboard(yamlContent: string): Storyboard {\n const parsed = parse(yamlContent) as Storyboard;\n if (!parsed?.id || !parsed?.phases) {\n throw new Error('Invalid storyboard YAML: missing required fields (id, phases)');\n }\n if (Object.prototype.hasOwnProperty.call(parsed, 'compliance_dir')) {\n throw new Error(\n 'Invalid storyboard YAML: compliance_dir is loader-owned runtime provenance; select an external cache with runner options instead.'\n );\n }\n for (const phase of parsed.phases) {\n // Specialism YAMLs may declare a phase with no `steps:` — the steps are\n // synthesized at runtime from fixtures (see request-signing/synthesize.ts).\n // Treat missing steps as an empty list so the parser stays phase-agnostic.\n if (!phase.steps) phase.steps = [];\n // YAML uses `name:` for context outputs but our runtime expects `key:`.\n for (const step of phase.steps) {\n if (!step.context_outputs) continue;\n for (const output of step.context_outputs) {\n const raw = output as unknown as Record<string, unknown>;\n if (raw.name && !raw.key) {\n output.key = raw.name as string;\n }\n }\n }\n }\n validateStoryboardShape(parsed);\n return parsed;\n}\n\n/** Load and parse a single storyboard file. Useful for ad-hoc testing of in-development YAMLs. */\nexport function loadStoryboardFile(filePath: string): Storyboard {\n return parseStoryboard(readFileSync(filePath, 'utf-8'));\n}\n\n/**\n * Enforce authoring-time invariants on a Storyboard. Called by\n * `parseStoryboard`, and should also be called by any runner entry point\n * that accepts a programmatically-built `Storyboard` object so the same\n * loud-fail-on-drift guarantee holds regardless of how the storyboard was\n * constructed. Mutates only legacy shorthand fields (resolves\n * `contributes: true` to `contributes_to`) and is idempotent on\n * already-validated inputs.\n */\nexport function validateStoryboardShape(storyboard: Storyboard): void {\n validateRequires(storyboard);\n validateRequiresAllCapabilities(storyboard);\n validateFixtureResolutionDeclarations(storyboard);\n validateRequiredAnyOfTools(storyboard);\n validatePhaseDependsOn(storyboard);\n for (const phase of storyboard.phases) {\n validateBranchSet(storyboard.id, phase);\n if (!phase.steps) continue;\n for (const step of phase.steps) {\n resolveContributesShorthand(storyboard.id, phase, step);\n validateFixtureForMutatingStep(storyboard.id, phase, step);\n validateOmitFlagCoherence(storyboard.id, phase, step);\n validateContextOutputs(storyboard.id, phase, step);\n validateUpstreamAttestationMode(storyboard.id, phase, step);\n validateUpstreamIdentifierPaths(storyboard.id, phase, step);\n validateAdvisoryDeclarations(storyboard.id, phase, step);\n validatePeerSubstitutesFor(storyboard.id, phase, step);\n }\n }\n}\n\nfunction validateRequiresAllCapabilities(storyboard: Storyboard): void {\n const predicates = storyboard.requires_all_capabilities;\n if (predicates === undefined) return;\n if (!Array.isArray(predicates) || predicates.length < 2) {\n throw new Error(\n `[${storyboard.id}] requires_all_capabilities: must list at least two predicates; use requires_capability for one`\n );\n }\n for (let index = 0; index < predicates.length; index++) {\n const raw = predicates[index] as unknown;\n const prefix = `[${storyboard.id}] requires_all_capabilities[${index}]`;\n if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {\n throw new Error(`${prefix}: must be a capability predicate object`);\n }\n const predicate = raw as Record<string, unknown>;\n if (typeof predicate.path !== 'string' || predicate.path.trim().length === 0) {\n throw new Error(`${prefix}.path: must be a non-empty string`);\n }\n if (!CAPABILITY_PATH_PATTERN.test(predicate.path)) {\n throw new Error(`${prefix}.path: must be a canonical dotted capability path`);\n }\n const matcherKeys = ['equals', 'present', 'contains', 'not_contains'].filter(key =>\n Object.prototype.hasOwnProperty.call(predicate, key)\n );\n if (matcherKeys.length !== 1) {\n throw new Error(`${prefix}: must declare exactly one of equals, present, contains, or not_contains`);\n }\n const unknownKeys = Object.keys(predicate).filter(key => key !== 'path' && !matcherKeys.includes(key));\n if (unknownKeys.length > 0) {\n throw new Error(`${prefix}: unknown field${unknownKeys.length === 1 ? '' : 's'} ${unknownKeys.join(', ')}`);\n }\n if (matcherKeys[0] === 'present' && typeof predicate.present !== 'boolean') {\n throw new Error(`${prefix}.present: must be a boolean`);\n }\n if (\n matcherKeys[0] === 'equals' &&\n predicate.equals !== null &&\n !['boolean', 'string', 'number'].includes(typeof predicate.equals)\n ) {\n throw new Error(`${prefix}.equals: must be a boolean, string, number, or null`);\n }\n if (\n (matcherKeys[0] === 'contains' || matcherKeys[0] === 'not_contains') &&\n !isJsonCapabilityValue(predicate[matcherKeys[0]!])\n ) {\n throw new Error(`${prefix}.${matcherKeys[0]}: must be a JSON-compatible capability value`);\n }\n }\n}\n\nfunction isJsonCapabilityValue(value: unknown, seen = new Set<object>()): boolean {\n if (value === null || ['boolean', 'string'].includes(typeof value)) return true;\n if (typeof value === 'number') return Number.isFinite(value);\n if (typeof value !== 'object') return false;\n if (seen.has(value)) return false;\n seen.add(value);\n const valid = Array.isArray(value)\n ? value.every(entry => isJsonCapabilityValue(entry, seen))\n : Object.getPrototypeOf(value) === Object.prototype &&\n Object.values(value as Record<string, unknown>).every(entry => isJsonCapabilityValue(entry, seen));\n seen.delete(value);\n return valid;\n}\n\nfunction validateAdvisoryDeclarations(\n storyboardId: string,\n phase: { id?: string },\n step: { id?: string; validations?: any[] }\n): void {\n for (let index = 0; index < (step.validations ?? []).length; index++) {\n const validation = step.validations![index];\n if (\n validation?.severity !== undefined &&\n validation.severity !== 'required' &&\n validation.severity !== 'advisory'\n ) {\n const prefix = `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${index}]`;\n throw new Error(`${prefix}.severity: must be either \"required\" or \"advisory\"`);\n }\n if (validation?.severity !== 'advisory') continue;\n const prefix = `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${index}]`;\n const hasExpiry = validation.expires_after_version !== undefined;\n const hasPermanent = validation.permanent_advisory !== undefined;\n if (hasExpiry === hasPermanent) {\n throw new Error(\n `${prefix}: severity \"advisory\" must declare exactly one of expires_after_version or permanent_advisory`\n );\n }\n if (\n hasExpiry &&\n (typeof validation.expires_after_version !== 'string' || !validSemver(validation.expires_after_version))\n ) {\n throw new Error(`${prefix}.expires_after_version: must be a valid semver string`);\n }\n if (\n hasPermanent &&\n (typeof validation.permanent_advisory !== 'object' ||\n validation.permanent_advisory === null ||\n typeof validation.permanent_advisory.reason !== 'string' ||\n validation.permanent_advisory.reason.trim().length === 0)\n ) {\n throw new Error(`${prefix}.permanent_advisory.reason: must be a non-empty string`);\n }\n }\n}\n\nfunction validateUpstreamAttestationMode(\n storyboardId: string,\n phase: { id?: string },\n step: { id?: string; validations?: any[] }\n): void {\n const validations = step.validations ?? [];\n for (let validationIndex = 0; validationIndex < validations.length; validationIndex++) {\n const validation = validations[validationIndex];\n if (validation?.check !== 'upstream_traffic') continue;\n const mode = validation.preferred_attestation_mode;\n if (mode !== undefined && mode !== 'raw' && mode !== 'digest') {\n throw new Error(\n `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${validationIndex}].preferred_attestation_mode: must be \"raw\" or \"digest\"`\n );\n }\n }\n}\n\nfunction validateUpstreamIdentifierPaths(\n storyboardId: string,\n phase: { id?: string },\n step: { id?: string; validations?: any[] }\n): void {\n const validations = step.validations ?? [];\n for (let validationIndex = 0; validationIndex < validations.length; validationIndex++) {\n const validation = validations[validationIndex];\n if (validation?.check !== 'upstream_traffic' || validation.identifier_paths === undefined) continue;\n if (!Array.isArray(validation.identifier_paths)) {\n throw new Error(\n `[${storyboardId}] ${phase.id ?? '?'}.${\n step.id ?? '?'\n }.validations[${validationIndex}].identifier_paths: must be an array of request-payload paths`\n );\n }\n for (let pathIndex = 0; pathIndex < validation.identifier_paths.length; pathIndex++) {\n const path = validation.identifier_paths[pathIndex];\n if (typeof path !== 'string' || path.length === 0) {\n throw new Error(\n `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${validationIndex}].identifier_paths[${pathIndex}]: must be a non-empty string`\n );\n }\n const pathErrorPrefix = `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${validationIndex}].identifier_paths[${pathIndex}]`;\n let firstSegment: string;\n try {\n const validated = validateIdentifierPathSyntax(path);\n firstSegment = validated.firstSegment;\n } catch {\n throw new Error(\n `${pathErrorPrefix}: \"${path}\" is unsupported; identifier_paths resolve only against the request payload or sample_request using dotted paths with [*] array selectors`\n );\n }\n const root = firstSegment.toLowerCase();\n if (root === 'request' || root === 'response' || root === 'context') {\n throw new Error(\n `${pathErrorPrefix}: \"${path}\" is unsupported; identifier_paths resolve only against the request payload or sample_request`\n );\n }\n }\n }\n}\n\nfunction validateIdentifierPathSyntax(path: string): { normalized: string; firstSegment: string } {\n const trimmed = path.trim();\n const normalized = trimmed.startsWith('$.') ? trimmed.slice(2) : trimmed;\n if (!IDENTIFIER_PATH_PATTERN.test(normalized)) {\n throw new Error('unsupported identifier path syntax');\n }\n return { normalized, firstSegment: normalized.split(/[.[\\]]/, 1)[0] ?? '' };\n}\n\nfunction validateRequiredAnyOfTools(storyboard: Storyboard): void {\n if (storyboard.required_any_of_tools === undefined) return;\n if (!Array.isArray(storyboard.required_any_of_tools)) {\n throw new Error(`[${storyboard.id}] required_any_of_tools: must be an array of tool-family objects`);\n }\n if (storyboard.required_any_of_tools.length === 0) {\n throw new Error(`[${storyboard.id}] required_any_of_tools: [] is not allowed — omit the field to use no gate`);\n }\n for (let i = 0; i < storyboard.required_any_of_tools.length; i++) {\n const family = storyboard.required_any_of_tools[i] as unknown;\n if (family === null || typeof family !== 'object' || Array.isArray(family)) {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}]: must be an object`);\n }\n const { tools, rationale } = family as { tools?: unknown; rationale?: unknown };\n if (!Array.isArray(tools) || tools.length < 2) {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}].tools: must list at least two tool names`);\n }\n for (const tool of tools) {\n if (typeof tool !== 'string' || tool.length === 0) {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}].tools: entries must be non-empty strings`);\n }\n }\n if (rationale !== undefined && typeof rationale !== 'string') {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}].rationale: must be a string`);\n }\n }\n}\n\n/**\n * Authoring-time validation for `phase.depends_on` (#1161). Each entry\n * must reference a phase declared earlier in the storyboard. Forward\n * references and self-references fail loud at parse time so authoring\n * mistakes (typos, reorderings) don't degrade silently into \"phase\n * always runs\" / \"phase always cascades.\"\n *\n * Rules:\n * - Empty list (`depends_on: []`) is legal — it declares an\n * independent phase. No further validation needed.\n * - Each non-empty entry must be a non-empty string.\n * - Each entry must reference a phase that appears EARLIER in the\n * `storyboard.phases[]` array (forward references are rejected).\n * - A phase cannot depend on itself.\n */\nfunction validatePhaseDependsOn(storyboard: Storyboard): void {\n const phaseIdsSeen = new Set<string>();\n for (const phase of storyboard.phases) {\n if (phase.depends_on !== undefined) {\n if (!Array.isArray(phase.depends_on)) {\n throw new Error(`[${storyboard.id}] phase '${phase.id}': depends_on must be an array of phase ids`);\n }\n for (const dep of phase.depends_on) {\n if (typeof dep !== 'string' || dep.length === 0) {\n throw new Error(`[${storyboard.id}] phase '${phase.id}': depends_on entries must be non-empty strings`);\n }\n if (dep === phase.id) {\n throw new Error(`[${storyboard.id}] phase '${phase.id}': depends_on cannot reference itself`);\n }\n if (!phaseIdsSeen.has(dep)) {\n throw new Error(\n `[${storyboard.id}] phase '${phase.id}': depends_on '${dep}' is not a phase declared earlier in this storyboard (forward and unknown references are rejected)`\n );\n }\n }\n }\n phaseIdsSeen.add(phase.id);\n }\n}\n\n/**\n * Authoring-time validation for `Storyboard.requires` (#1626). The field is\n * an array of non-empty requirement names:\n *\n * - `requires: []` is rejected — an empty array reads as \"no\n * requirements,\" which is the same as omitting the field; failing\n * load forces the author to omit it explicitly.\n * - Each entry must be a non-empty string.\n *\n * Unknown string values are allowed for forward compatibility. Runners that\n * don't know how to satisfy a future requirement skip at runtime with\n * `skip_reason: 'requirement_unmet'` and the authored value in\n * `skip.requirement`.\n */\nfunction validateRequires(storyboard: Storyboard): void {\n if (storyboard.requires === undefined) return;\n if (!Array.isArray(storyboard.requires)) {\n throw new Error(\n `[${storyboard.id}] requires: must be an array of requirement names (got ${typeof storyboard.requires})`\n );\n }\n if (storyboard.requires.length === 0) {\n throw new Error(`[${storyboard.id}] requires: [] is not allowed — omit the field to use the default ([real_wire])`);\n }\n for (let i = 0; i < storyboard.requires.length; i++) {\n const name = storyboard.requires[i];\n if (typeof name !== 'string' || name.length === 0) {\n throw new Error(`[${storyboard.id}] requires[${i}]: entries must be non-empty strings`);\n }\n }\n}\n\n/**\n * Issue #820: mutating tasks (per {@link MUTATING_TASKS}) must have a\n * `sample_request` authored. The fixture is authoritative at run time —\n * there's no sane default payload for a write, and silently fabricating\n * one was the bug factory that produced #780 / #792 / #793 / #802 / #805.\n *\n * Error messages point at the task name, the step id, the storyboard, and\n * suggest the concrete author action.\n *\n * Opt-out: steps with `expect_error: true` that deliberately exercise\n * missing-fixture / malformed-payload seller behavior skip this check —\n * the author is signaling the payload is the test condition.\n *\n * Synthesized phases (`request-signing/synthesize.ts`, controller seeding)\n * start with `phase.steps = []` in YAML and the loader doesn't see the\n * runtime-generated steps, so those paths are not affected.\n */\nfunction validateFixtureForMutatingStep(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n if (!MUTATING_TASKS.has(step.task)) return;\n if (step.sample_request !== undefined) return;\n if (step.expect_error === true) return;\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}' (task=${step.task}): ` +\n `mutating tasks require a sample_request fixture — the runner no longer fabricates ` +\n `write payloads. Author sample_request in the step or, for intentionally malformed ` +\n `payloads, set expect_error: true.`\n );\n}\n\n/**\n * `omit_account: true` must be paired with `expect_error: true`.\n *\n * An accountless `create_media_buy` will always be rejected by a spec-compliant\n * seller; a step that sets `omit_account` without `expect_error` will be graded\n * as a failure (not a controlled negative test), producing a misleading\n * compliance result. Fail loud at parse time so the author sees the problem\n * during storyboard load, not at run time.\n */\nfunction validateOmitFlagCoherence(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n if (step.omit_account && step.expect_error !== true) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ` +\n `omit_account: true requires expect_error: true — an accountless ` +\n `create_media_buy will always be rejected by a spec-compliant seller.`\n );\n }\n}\n\n/**\n * Each `context_outputs` entry must declare exactly one source: either\n * `path` (extract from response) or `generate` (mint at run time). An entry\n * with neither is a silent no-op; one with both would silently pick `generate`\n * and ignore `path`. Both are authoring foot-guns that should fail loud.\n */\nfunction validateContextOutputs(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n if (!step.context_outputs?.length) return;\n for (const output of step.context_outputs) {\n const hasPath = output.path !== undefined;\n const hasGenerate = output.generate !== undefined;\n if (!hasPath && !hasGenerate) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': context_outputs entry ` +\n `'${output.key}' must set exactly one of 'path' or 'generate'.`\n );\n }\n if (hasPath && hasGenerate) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': context_outputs entry ` +\n `'${output.key}' sets both 'path' and 'generate' — they are mutually exclusive.`\n );\n }\n // Validate generator name. The runtime resolver also checks but the loader\n // catches typos at storyboard-load time so authors see the failure on\n // build, not on the first run.\n if (hasGenerate && output.generate !== 'uuid_v4' && output.generate !== 'opaque_id') {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': context_outputs entry ` +\n `'${output.key}' has unknown generate value '${output.generate}'. ` +\n `Supported: 'uuid_v4', 'opaque_id'.`\n );\n }\n }\n}\n\n/**\n * Authoring-time validation for `provides_state_for` (the AdCP 3.0.3 spec\n * field — adcp#3734) and the legacy `peer_substitutes_for` synonym. The\n * runner treats the field as same-phase-only and substitution-only-when-\n * stateful; surface those constraints at parse time so storyboard authors\n * see typos and cross-phase references on build, not as a silent no-rescue\n * at run time.\n *\n * Both field names parse to the same canonical normalized form on the step\n * object (the spec name `provides_state_for` is preferred when both are\n * declared). The deprecation alias is documented in `types.ts`.\n *\n * Rules:\n * - Each target must reference a step that exists in the same phase.\n * - A step cannot substitute for itself.\n * - The substitute step itself must be `stateful: true` — non-stateful\n * passes don't establish state per the cascade contract.\n * - The target step must be `stateful: true` — non-stateful targets\n * don't participate in cascade gating, so a substitution declaration\n * would be a no-op.\n * - When both fields are declared on the same step, they must match\n * element-for-element (the deprecation contract is \"synonym for\", not\n * \"additive with\").\n */\nfunction validatePeerSubstitutesFor(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n const newField = step.provides_state_for;\n const legacyField = step.peer_substitutes_for;\n if (newField === undefined && legacyField === undefined) return;\n\n if (newField !== undefined && legacyField !== undefined) {\n // Order-sensitive equality: `[A, B]` vs `[B, A]` would throw despite being\n // semantically equivalent. Authors mid-migration should write the same list\n // in both fields; the deprecation alias is a literal synonym, not a\n // same-set restatement.\n const a = JSON.stringify(Array.isArray(newField) ? newField : [newField]);\n const b = JSON.stringify(Array.isArray(legacyField) ? legacyField : [legacyField]);\n if (a !== b) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': both provides_state_for and ` +\n `peer_substitutes_for declared with different values — pick one (provides_state_for is the ` +\n `spec field; peer_substitutes_for is a deprecated synonym)`\n );\n }\n }\n\n // Normalize onto provides_state_for so the runner can read a single field.\n // peer_substitutes_for stays for back-compat with any consumer code that\n // already reads it.\n if (newField === undefined && legacyField !== undefined) {\n step.provides_state_for = legacyField;\n } else if (newField !== undefined && legacyField === undefined) {\n step.peer_substitutes_for = newField;\n }\n\n const sourceFieldName = newField !== undefined ? 'provides_state_for' : 'peer_substitutes_for';\n const declared = step.provides_state_for!;\n const targets = Array.isArray(declared) ? declared : [declared];\n if (!step.stateful) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} is only legal on stateful steps`\n );\n }\n const phaseStepIds = new Map(phase.steps.map(s => [s.id, s]));\n for (const target of targets) {\n if (typeof target !== 'string' || target.length === 0) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} entries must be non-empty strings`\n );\n }\n if (target === step.id) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} cannot reference itself`\n );\n }\n const targetStep = phaseStepIds.get(target);\n if (!targetStep) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} target '${target}' is not a step in this phase (same-phase only)`\n );\n }\n if (!targetStep.stateful) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} target '${target}' must be stateful`\n );\n }\n }\n}\n\nfunction validateBranchSet(storyboardId: string, phase: Storyboard['phases'][number]): void {\n if (phase.branch_set === undefined) return;\n const bs = phase.branch_set as unknown;\n if (!bs || typeof bs !== 'object') {\n throw new Error(`[${storyboardId}] phase '${phase.id}': branch_set must be an object with { id, semantics }`);\n }\n const { id, semantics } = bs as Record<string, unknown>;\n if (typeof id !== 'string' || id.length === 0) {\n throw new Error(`[${storyboardId}] phase '${phase.id}': branch_set.id must be a non-empty string`);\n }\n if (typeof semantics !== 'string' || semantics.length === 0) {\n throw new Error(`[${storyboardId}] phase '${phase.id}': branch_set.semantics must be a non-empty string`);\n }\n // Only `any_of` is defined in AdCP today (adcp#2646 lint rule 2 —\n // `at_least_n` and `all_of` are reserved but not defined). Reject unknown\n // values at parse rather than silently skipping grading at runtime, so\n // spec-drift typos fail loud instead of degrading to raw `failed` peers.\n if (!(BRANCH_SET_SEMANTICS as readonly string[]).includes(semantics)) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}': branch_set.semantics='${semantics}' is not supported (valid: ${BRANCH_SET_SEMANTICS.join(', ')})`\n );\n }\n // Schema constraint: every phase in a branch set MUST be optional. A\n // non-optional branch-set phase would fail the storyboard on any step\n // failure regardless of peer contribution, defeating the any_of gate.\n if (phase.optional !== true) {\n throw new Error(`[${storyboardId}] phase '${phase.id}': phases declaring branch_set must set 'optional: true'`);\n }\n}\n\n/**\n * Resolve the `contributes: true` boolean shorthand introduced alongside the\n * first-class `branch_set:` phase field (adcp-client#693, adcp#2646).\n *\n * Rules:\n * - `contributes: true` is legal only inside a phase that declares `branch_set:`.\n * - A step MUST NOT set both `contributes` and `contributes_to` (ambiguous).\n * - A string `contributes_to` inside a branch_set phase MUST equal `branch_set.id`\n * (otherwise the aggregation target drifts — same invariant the spec lint enforces).\n *\n * After resolution, `step.contributes_to` carries the flag name and `step.contributes`\n * is cleared, so the runner reads a single field regardless of authoring form.\n */\nfunction resolveContributesShorthand(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n const hasBoolean = step.contributes !== undefined;\n const hasString = step.contributes_to !== undefined;\n\n if (hasBoolean && hasString) {\n throw new Error(`[${storyboardId}] step '${step.id}' declares both 'contributes' and 'contributes_to' — pick one`);\n }\n\n if (hasBoolean) {\n if (step.contributes === true) {\n if (!phase.branch_set) {\n throw new Error(\n `[${storyboardId}] step '${step.id}': 'contributes: true' is only legal inside a phase that declares branch_set`\n );\n }\n step.contributes_to = phase.branch_set.id;\n }\n delete step.contributes;\n return;\n }\n\n if (hasString && phase.branch_set && step.contributes_to !== phase.branch_set.id) {\n throw new Error(\n `[${storyboardId}] step '${step.id}': contributes_to='${step.contributes_to}' must equal enclosing phase's branch_set.id='${phase.branch_set.id}'`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,gBAA6B;AAC7B,kBAAsB;AAEtB,yBAA+B;AAC/B,gCAAsD;AACtD,oBAAqC;AAO9B,MAAM,uBAAuB,CAAC,QAAQ;AAE7C,MAAM,0BAA0B,OAAO;AACvC,MAAM,0BAA0B,IAAI,OAAO,IAAI,uBAAuB,SAAS,uBAAuB,KAAK;AAC3G,MAAM,0BAA0B;AAGzB,SAAS,gBAAgB,aAAiC;AAC/D,QAAM,aAAS,mBAAM,WAAW;AAChC,MAAI,CAAC,QAAQ,MAAM,CAAC,QAAQ,QAAQ;AAClC,UAAM,IAAI,MAAM,+DAA+D;AAAA,EACjF;AACA,MAAI,OAAO,UAAU,eAAe,KAAK,QAAQ,gBAAgB,GAAG;AAClE,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,aAAW,SAAS,OAAO,QAAQ;AAIjC,QAAI,CAAC,MAAM,MAAO,OAAM,QAAQ,CAAC;AAEjC,eAAW,QAAQ,MAAM,OAAO;AAC9B,UAAI,CAAC,KAAK,gBAAiB;AAC3B,iBAAW,UAAU,KAAK,iBAAiB;AACzC,cAAM,MAAM;AACZ,YAAI,IAAI,QAAQ,CAAC,IAAI,KAAK;AACxB,iBAAO,MAAM,IAAI;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,0BAAwB,MAAM;AAC9B,SAAO;AACT;AAGO,SAAS,mBAAmB,UAA8B;AAC/D,SAAO,oBAAgB,wBAAa,UAAU,OAAO,CAAC;AACxD;AAWO,SAAS,wBAAwB,YAA8B;AACpE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DAAoD;AAAA,EAC1G;AAKA,MAAI,CAAE,qBAA2C,SAAS,SAAS,GAAG;AACpE,UAAM,IAAI;AAAA,MACR,IAAI,YAAY,YAAY,MAAM,EAAE,4BAA4B,SAAS,8BAA8B,qBAAqB,KAAK,IAAI,CAAC;AAAA,IACxI;AAAA,EACF;AAIA,MAAI,MAAM,aAAa,MAAM;AAC3B,UAAM,IAAI,MAAM,IAAI,YAAY,YAAY,MAAM,EAAE,0DAA0D;AAAA,EAChH;AACF;AAeA,SAAS,4BACP,cACA,OACA,MACM;AACN,QAAM,aAAa,KAAK,gBAAgB;AACxC,QAAM,YAAY,KAAK,mBAAmB;AAE1C,MAAI,cAAc,WAAW;AAC3B,UAAM,IAAI,MAAM,IAAI,YAAY,WAAW,KAAK,EAAE,oEAA+D;AAAA,EACnH;AAEA,MAAI,YAAY;AACd,QAAI,KAAK,gBAAgB,MAAM;AAC7B,UAAI,CAAC,MAAM,YAAY;AACrB,cAAM,IAAI;AAAA,UACR,IAAI,YAAY,WAAW,KAAK,EAAE;AAAA,QACpC;AAAA,MACF;AACA,WAAK,iBAAiB,MAAM,WAAW;AAAA,IACzC;AACA,WAAO,KAAK;AACZ;AAAA,EACF;AAEA,MAAI,aAAa,MAAM,cAAc,KAAK,mBAAmB,MAAM,WAAW,IAAI;AAChF,UAAM,IAAI;AAAA,MACR,IAAI,YAAY,WAAW,KAAK,EAAE,sBAAsB,KAAK,cAAc,iDAAiD,MAAM,WAAW,EAAE;AAAA,IACjJ;AAAA,EACF;AACF;","names":["prefix","validSemver"]}
1
+ {"version":3,"sources":["../../../../src/lib/testing/storyboard/loader.ts"],"sourcesContent":["/**\n * Storyboard YAML parser.\n *\n * Storyboards are pulled from the compliance cache populated by\n * `npm run sync-schemas`. See `./compliance.ts` for capability-driven\n * resolution and bundle loading.\n */\n\nimport { readFileSync } from 'fs';\nimport { parse } from 'yaml';\nimport type { Storyboard } from './types';\nimport { MUTATING_TASKS } from '../../utils/idempotency';\nimport { validateFixtureResolutionDeclarations } from './fixture-resolution';\nimport { valid as validSemver } from 'semver';\nimport { parsePhaseCondition } from './phase-condition';\n\n/**\n * Supported `branch_set.semantics` values. Extend when AdCP adds `all_of`,\n * `at_least_n`, etc. Exported so the runner can enforce the same whitelist\n * on programmatically-constructed storyboards that bypass the YAML parser.\n */\nexport const BRANCH_SET_SEMANTICS = ['any_of'] as const;\n\nconst IDENTIFIER_PATH_SEGMENT = String.raw`[A-Za-z_][A-Za-z0-9_-]*(?:\\[\\*\\])*`;\nconst IDENTIFIER_PATH_PATTERN = new RegExp(`^${IDENTIFIER_PATH_SEGMENT}(?:\\\\.${IDENTIFIER_PATH_SEGMENT})*$`);\nconst CAPABILITY_PATH_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*(?:\\.[A-Za-z_][A-Za-z0-9_-]*)*$/;\n\n/** Parse a YAML string into a Storyboard. Throws if required fields are missing. */\nexport function parseStoryboard(yamlContent: string): Storyboard {\n const parsed = parse(yamlContent) as Storyboard;\n if (!parsed?.id || !parsed?.phases) {\n throw new Error('Invalid storyboard YAML: missing required fields (id, phases)');\n }\n if (Object.prototype.hasOwnProperty.call(parsed, 'compliance_dir')) {\n throw new Error(\n 'Invalid storyboard YAML: compliance_dir is loader-owned runtime provenance; select an external cache with runner options instead.'\n );\n }\n for (const phase of parsed.phases) {\n // Specialism YAMLs may declare a phase with no `steps:` — the steps are\n // synthesized at runtime from fixtures (see request-signing/synthesize.ts).\n // Treat missing steps as an empty list so the parser stays phase-agnostic.\n if (!phase.steps) phase.steps = [];\n // YAML uses `name:` for context outputs but our runtime expects `key:`.\n for (const step of phase.steps) {\n if (!step.context_outputs) continue;\n for (const output of step.context_outputs) {\n const raw = output as unknown as Record<string, unknown>;\n if (raw.name && !raw.key) {\n output.key = raw.name as string;\n }\n }\n }\n }\n validateStoryboardShape(parsed);\n return parsed;\n}\n\n/** Load and parse a single storyboard file. Useful for ad-hoc testing of in-development YAMLs. */\nexport function loadStoryboardFile(filePath: string): Storyboard {\n return parseStoryboard(readFileSync(filePath, 'utf-8'));\n}\n\n/**\n * Enforce authoring-time invariants on a Storyboard. Called by\n * `parseStoryboard`, and should also be called by any runner entry point\n * that accepts a programmatically-built `Storyboard` object so the same\n * loud-fail-on-drift guarantee holds regardless of how the storyboard was\n * constructed. Mutates only legacy shorthand fields (resolves\n * `contributes: true` to `contributes_to`) and is idempotent on\n * already-validated inputs.\n */\nexport function validateStoryboardShape(storyboard: Storyboard): void {\n validateRequires(storyboard);\n validateRequiresAllCapabilities(storyboard);\n validateFixtureResolutionDeclarations(storyboard);\n validateRequiredAnyOfTools(storyboard);\n validatePhaseDependsOn(storyboard);\n for (const phase of storyboard.phases) {\n validatePhaseSkipIf(storyboard.id, phase);\n validateBranchSet(storyboard.id, phase);\n if (!phase.steps) continue;\n for (const step of phase.steps) {\n resolveContributesShorthand(storyboard.id, phase, step);\n validateFixtureForMutatingStep(storyboard.id, phase, step);\n validateOmitFlagCoherence(storyboard.id, phase, step);\n validateContextOutputs(storyboard.id, phase, step);\n validateUpstreamAttestationMode(storyboard.id, phase, step);\n validateUpstreamIdentifierPaths(storyboard.id, phase, step);\n validateAdvisoryDeclarations(storyboard.id, phase, step);\n validatePeerSubstitutesFor(storyboard.id, phase, step);\n }\n }\n}\n\nfunction validatePhaseSkipIf(storyboardId: string, phase: Storyboard['phases'][number]): void {\n if (phase.skip_if === undefined) return;\n if (typeof phase.skip_if !== 'string') {\n throw new Error(`[${storyboardId}] phase '${phase.id}': skip_if must be a string`);\n }\n try {\n parsePhaseCondition(phase.skip_if);\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error);\n throw new Error(`[${storyboardId}] phase '${phase.id}': ${detail}`);\n }\n}\n\nfunction validateRequiresAllCapabilities(storyboard: Storyboard): void {\n const predicates = storyboard.requires_all_capabilities;\n if (predicates === undefined) return;\n if (!Array.isArray(predicates) || predicates.length < 2) {\n throw new Error(\n `[${storyboard.id}] requires_all_capabilities: must list at least two predicates; use requires_capability for one`\n );\n }\n for (let index = 0; index < predicates.length; index++) {\n const raw = predicates[index] as unknown;\n const prefix = `[${storyboard.id}] requires_all_capabilities[${index}]`;\n if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {\n throw new Error(`${prefix}: must be a capability predicate object`);\n }\n const predicate = raw as Record<string, unknown>;\n if (typeof predicate.path !== 'string' || predicate.path.trim().length === 0) {\n throw new Error(`${prefix}.path: must be a non-empty string`);\n }\n if (!CAPABILITY_PATH_PATTERN.test(predicate.path)) {\n throw new Error(`${prefix}.path: must be a canonical dotted capability path`);\n }\n const matcherKeys = ['equals', 'present', 'contains', 'not_contains'].filter(key =>\n Object.prototype.hasOwnProperty.call(predicate, key)\n );\n if (matcherKeys.length !== 1) {\n throw new Error(`${prefix}: must declare exactly one of equals, present, contains, or not_contains`);\n }\n const unknownKeys = Object.keys(predicate).filter(key => key !== 'path' && !matcherKeys.includes(key));\n if (unknownKeys.length > 0) {\n throw new Error(`${prefix}: unknown field${unknownKeys.length === 1 ? '' : 's'} ${unknownKeys.join(', ')}`);\n }\n if (matcherKeys[0] === 'present' && typeof predicate.present !== 'boolean') {\n throw new Error(`${prefix}.present: must be a boolean`);\n }\n if (\n matcherKeys[0] === 'equals' &&\n predicate.equals !== null &&\n !['boolean', 'string', 'number'].includes(typeof predicate.equals)\n ) {\n throw new Error(`${prefix}.equals: must be a boolean, string, number, or null`);\n }\n if (\n (matcherKeys[0] === 'contains' || matcherKeys[0] === 'not_contains') &&\n !isJsonCapabilityValue(predicate[matcherKeys[0]!])\n ) {\n throw new Error(`${prefix}.${matcherKeys[0]}: must be a JSON-compatible capability value`);\n }\n }\n}\n\nfunction isJsonCapabilityValue(value: unknown, seen = new Set<object>()): boolean {\n if (value === null || ['boolean', 'string'].includes(typeof value)) return true;\n if (typeof value === 'number') return Number.isFinite(value);\n if (typeof value !== 'object') return false;\n if (seen.has(value)) return false;\n seen.add(value);\n const valid = Array.isArray(value)\n ? value.every(entry => isJsonCapabilityValue(entry, seen))\n : Object.getPrototypeOf(value) === Object.prototype &&\n Object.values(value as Record<string, unknown>).every(entry => isJsonCapabilityValue(entry, seen));\n seen.delete(value);\n return valid;\n}\n\nfunction validateAdvisoryDeclarations(\n storyboardId: string,\n phase: { id?: string },\n step: { id?: string; validations?: any[] }\n): void {\n for (let index = 0; index < (step.validations ?? []).length; index++) {\n const validation = step.validations![index];\n if (\n validation?.severity !== undefined &&\n validation.severity !== 'required' &&\n validation.severity !== 'advisory'\n ) {\n const prefix = `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${index}]`;\n throw new Error(`${prefix}.severity: must be either \"required\" or \"advisory\"`);\n }\n if (validation?.severity !== 'advisory') continue;\n const prefix = `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${index}]`;\n const hasExpiry = validation.expires_after_version !== undefined;\n const hasPermanent = validation.permanent_advisory !== undefined;\n if (hasExpiry === hasPermanent) {\n throw new Error(\n `${prefix}: severity \"advisory\" must declare exactly one of expires_after_version or permanent_advisory`\n );\n }\n if (\n hasExpiry &&\n (typeof validation.expires_after_version !== 'string' || !validSemver(validation.expires_after_version))\n ) {\n throw new Error(`${prefix}.expires_after_version: must be a valid semver string`);\n }\n if (\n hasPermanent &&\n (typeof validation.permanent_advisory !== 'object' ||\n validation.permanent_advisory === null ||\n typeof validation.permanent_advisory.reason !== 'string' ||\n validation.permanent_advisory.reason.trim().length === 0)\n ) {\n throw new Error(`${prefix}.permanent_advisory.reason: must be a non-empty string`);\n }\n }\n}\n\nfunction validateUpstreamAttestationMode(\n storyboardId: string,\n phase: { id?: string },\n step: { id?: string; validations?: any[] }\n): void {\n const validations = step.validations ?? [];\n for (let validationIndex = 0; validationIndex < validations.length; validationIndex++) {\n const validation = validations[validationIndex];\n if (validation?.check !== 'upstream_traffic') continue;\n const mode = validation.preferred_attestation_mode;\n if (mode !== undefined && mode !== 'raw' && mode !== 'digest') {\n throw new Error(\n `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${validationIndex}].preferred_attestation_mode: must be \"raw\" or \"digest\"`\n );\n }\n }\n}\n\nfunction validateUpstreamIdentifierPaths(\n storyboardId: string,\n phase: { id?: string },\n step: { id?: string; validations?: any[] }\n): void {\n const validations = step.validations ?? [];\n for (let validationIndex = 0; validationIndex < validations.length; validationIndex++) {\n const validation = validations[validationIndex];\n if (validation?.check !== 'upstream_traffic' || validation.identifier_paths === undefined) continue;\n if (!Array.isArray(validation.identifier_paths)) {\n throw new Error(\n `[${storyboardId}] ${phase.id ?? '?'}.${\n step.id ?? '?'\n }.validations[${validationIndex}].identifier_paths: must be an array of request-payload paths`\n );\n }\n for (let pathIndex = 0; pathIndex < validation.identifier_paths.length; pathIndex++) {\n const path = validation.identifier_paths[pathIndex];\n if (typeof path !== 'string' || path.length === 0) {\n throw new Error(\n `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${validationIndex}].identifier_paths[${pathIndex}]: must be a non-empty string`\n );\n }\n const pathErrorPrefix = `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${validationIndex}].identifier_paths[${pathIndex}]`;\n let firstSegment: string;\n try {\n const validated = validateIdentifierPathSyntax(path);\n firstSegment = validated.firstSegment;\n } catch {\n throw new Error(\n `${pathErrorPrefix}: \"${path}\" is unsupported; identifier_paths resolve only against the request payload or sample_request using dotted paths with [*] array selectors`\n );\n }\n const root = firstSegment.toLowerCase();\n if (root === 'request' || root === 'response' || root === 'context') {\n throw new Error(\n `${pathErrorPrefix}: \"${path}\" is unsupported; identifier_paths resolve only against the request payload or sample_request`\n );\n }\n }\n }\n}\n\nfunction validateIdentifierPathSyntax(path: string): { normalized: string; firstSegment: string } {\n const trimmed = path.trim();\n const normalized = trimmed.startsWith('$.') ? trimmed.slice(2) : trimmed;\n if (!IDENTIFIER_PATH_PATTERN.test(normalized)) {\n throw new Error('unsupported identifier path syntax');\n }\n return { normalized, firstSegment: normalized.split(/[.[\\]]/, 1)[0] ?? '' };\n}\n\nfunction validateRequiredAnyOfTools(storyboard: Storyboard): void {\n if (storyboard.required_any_of_tools === undefined) return;\n if (!Array.isArray(storyboard.required_any_of_tools)) {\n throw new Error(`[${storyboard.id}] required_any_of_tools: must be an array of tool-family objects`);\n }\n if (storyboard.required_any_of_tools.length === 0) {\n throw new Error(`[${storyboard.id}] required_any_of_tools: [] is not allowed — omit the field to use no gate`);\n }\n for (let i = 0; i < storyboard.required_any_of_tools.length; i++) {\n const family = storyboard.required_any_of_tools[i] as unknown;\n if (family === null || typeof family !== 'object' || Array.isArray(family)) {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}]: must be an object`);\n }\n const { tools, rationale } = family as { tools?: unknown; rationale?: unknown };\n if (!Array.isArray(tools) || tools.length < 2) {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}].tools: must list at least two tool names`);\n }\n for (const tool of tools) {\n if (typeof tool !== 'string' || tool.length === 0) {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}].tools: entries must be non-empty strings`);\n }\n }\n if (rationale !== undefined && typeof rationale !== 'string') {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}].rationale: must be a string`);\n }\n }\n}\n\n/**\n * Authoring-time validation for `phase.depends_on` (#1161). Each entry\n * must reference a phase declared earlier in the storyboard. Forward\n * references and self-references fail loud at parse time so authoring\n * mistakes (typos, reorderings) don't degrade silently into \"phase\n * always runs\" / \"phase always cascades.\"\n *\n * Rules:\n * - Empty list (`depends_on: []`) is legal — it declares an\n * independent phase. No further validation needed.\n * - Each non-empty entry must be a non-empty string.\n * - Each entry must reference a phase that appears EARLIER in the\n * `storyboard.phases[]` array (forward references are rejected).\n * - A phase cannot depend on itself.\n */\nfunction validatePhaseDependsOn(storyboard: Storyboard): void {\n const phaseIdsSeen = new Set<string>();\n for (const phase of storyboard.phases) {\n if (phase.depends_on !== undefined) {\n if (!Array.isArray(phase.depends_on)) {\n throw new Error(`[${storyboard.id}] phase '${phase.id}': depends_on must be an array of phase ids`);\n }\n for (const dep of phase.depends_on) {\n if (typeof dep !== 'string' || dep.length === 0) {\n throw new Error(`[${storyboard.id}] phase '${phase.id}': depends_on entries must be non-empty strings`);\n }\n if (dep === phase.id) {\n throw new Error(`[${storyboard.id}] phase '${phase.id}': depends_on cannot reference itself`);\n }\n if (!phaseIdsSeen.has(dep)) {\n throw new Error(\n `[${storyboard.id}] phase '${phase.id}': depends_on '${dep}' is not a phase declared earlier in this storyboard (forward and unknown references are rejected)`\n );\n }\n }\n }\n phaseIdsSeen.add(phase.id);\n }\n}\n\n/**\n * Authoring-time validation for `Storyboard.requires` (#1626). The field is\n * an array of non-empty requirement names:\n *\n * - `requires: []` is rejected — an empty array reads as \"no\n * requirements,\" which is the same as omitting the field; failing\n * load forces the author to omit it explicitly.\n * - Each entry must be a non-empty string.\n *\n * Unknown string values are allowed for forward compatibility. Runners that\n * don't know how to satisfy a future requirement skip at runtime with\n * `skip_reason: 'requirement_unmet'` and the authored value in\n * `skip.requirement`.\n */\nfunction validateRequires(storyboard: Storyboard): void {\n if (storyboard.requires === undefined) return;\n if (!Array.isArray(storyboard.requires)) {\n throw new Error(\n `[${storyboard.id}] requires: must be an array of requirement names (got ${typeof storyboard.requires})`\n );\n }\n if (storyboard.requires.length === 0) {\n throw new Error(`[${storyboard.id}] requires: [] is not allowed — omit the field to use the default ([real_wire])`);\n }\n for (let i = 0; i < storyboard.requires.length; i++) {\n const name = storyboard.requires[i];\n if (typeof name !== 'string' || name.length === 0) {\n throw new Error(`[${storyboard.id}] requires[${i}]: entries must be non-empty strings`);\n }\n }\n}\n\n/**\n * Issue #820: mutating tasks (per {@link MUTATING_TASKS}) must have a\n * `sample_request` authored. The fixture is authoritative at run time —\n * there's no sane default payload for a write, and silently fabricating\n * one was the bug factory that produced #780 / #792 / #793 / #802 / #805.\n *\n * Error messages point at the task name, the step id, the storyboard, and\n * suggest the concrete author action.\n *\n * Opt-out: steps with `expect_error: true` that deliberately exercise\n * missing-fixture / malformed-payload seller behavior skip this check —\n * the author is signaling the payload is the test condition.\n *\n * Synthesized phases (`request-signing/synthesize.ts`, controller seeding)\n * start with `phase.steps = []` in YAML and the loader doesn't see the\n * runtime-generated steps, so those paths are not affected.\n */\nfunction validateFixtureForMutatingStep(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n if (!MUTATING_TASKS.has(step.task)) return;\n if (step.sample_request !== undefined) return;\n if (step.expect_error === true) return;\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}' (task=${step.task}): ` +\n `mutating tasks require a sample_request fixture — the runner no longer fabricates ` +\n `write payloads. Author sample_request in the step or, for intentionally malformed ` +\n `payloads, set expect_error: true.`\n );\n}\n\n/**\n * `omit_account: true` must be paired with `expect_error: true`.\n *\n * An accountless `create_media_buy` will always be rejected by a spec-compliant\n * seller; a step that sets `omit_account` without `expect_error` will be graded\n * as a failure (not a controlled negative test), producing a misleading\n * compliance result. Fail loud at parse time so the author sees the problem\n * during storyboard load, not at run time.\n */\nfunction validateOmitFlagCoherence(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n if (step.omit_account && step.expect_error !== true) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ` +\n `omit_account: true requires expect_error: true — an accountless ` +\n `create_media_buy will always be rejected by a spec-compliant seller.`\n );\n }\n}\n\n/**\n * Each `context_outputs` entry must declare exactly one source: either\n * `path` (extract from response) or `generate` (mint at run time). An entry\n * with neither is a silent no-op; one with both would silently pick `generate`\n * and ignore `path`. Both are authoring foot-guns that should fail loud.\n */\nfunction validateContextOutputs(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n if (!step.context_outputs?.length) return;\n for (const output of step.context_outputs) {\n const hasPath = output.path !== undefined;\n const hasGenerate = output.generate !== undefined;\n if (!hasPath && !hasGenerate) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': context_outputs entry ` +\n `'${output.key}' must set exactly one of 'path' or 'generate'.`\n );\n }\n if (hasPath && hasGenerate) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': context_outputs entry ` +\n `'${output.key}' sets both 'path' and 'generate' — they are mutually exclusive.`\n );\n }\n // Validate generator name. The runtime resolver also checks but the loader\n // catches typos at storyboard-load time so authors see the failure on\n // build, not on the first run.\n if (hasGenerate && output.generate !== 'uuid_v4' && output.generate !== 'opaque_id') {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': context_outputs entry ` +\n `'${output.key}' has unknown generate value '${output.generate}'. ` +\n `Supported: 'uuid_v4', 'opaque_id'.`\n );\n }\n }\n}\n\n/**\n * Authoring-time validation for `provides_state_for` (the AdCP 3.0.3 spec\n * field — adcp#3734) and the legacy `peer_substitutes_for` synonym. The\n * runner treats the field as same-phase-only and substitution-only-when-\n * stateful; surface those constraints at parse time so storyboard authors\n * see typos and cross-phase references on build, not as a silent no-rescue\n * at run time.\n *\n * Both field names parse to the same canonical normalized form on the step\n * object (the spec name `provides_state_for` is preferred when both are\n * declared). The deprecation alias is documented in `types.ts`.\n *\n * Rules:\n * - Each target must reference a step that exists in the same phase.\n * - A step cannot substitute for itself.\n * - The substitute step itself must be `stateful: true` — non-stateful\n * passes don't establish state per the cascade contract.\n * - The target step must be `stateful: true` — non-stateful targets\n * don't participate in cascade gating, so a substitution declaration\n * would be a no-op.\n * - When both fields are declared on the same step, they must match\n * element-for-element (the deprecation contract is \"synonym for\", not\n * \"additive with\").\n */\nfunction validatePeerSubstitutesFor(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n const newField = step.provides_state_for;\n const legacyField = step.peer_substitutes_for;\n if (newField === undefined && legacyField === undefined) return;\n\n if (newField !== undefined && legacyField !== undefined) {\n // Order-sensitive equality: `[A, B]` vs `[B, A]` would throw despite being\n // semantically equivalent. Authors mid-migration should write the same list\n // in both fields; the deprecation alias is a literal synonym, not a\n // same-set restatement.\n const a = JSON.stringify(Array.isArray(newField) ? newField : [newField]);\n const b = JSON.stringify(Array.isArray(legacyField) ? legacyField : [legacyField]);\n if (a !== b) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': both provides_state_for and ` +\n `peer_substitutes_for declared with different values — pick one (provides_state_for is the ` +\n `spec field; peer_substitutes_for is a deprecated synonym)`\n );\n }\n }\n\n // Normalize onto provides_state_for so the runner can read a single field.\n // peer_substitutes_for stays for back-compat with any consumer code that\n // already reads it.\n if (newField === undefined && legacyField !== undefined) {\n step.provides_state_for = legacyField;\n } else if (newField !== undefined && legacyField === undefined) {\n step.peer_substitutes_for = newField;\n }\n\n const sourceFieldName = newField !== undefined ? 'provides_state_for' : 'peer_substitutes_for';\n const declared = step.provides_state_for!;\n const targets = Array.isArray(declared) ? declared : [declared];\n if (!step.stateful) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} is only legal on stateful steps`\n );\n }\n const phaseStepIds = new Map(phase.steps.map(s => [s.id, s]));\n for (const target of targets) {\n if (typeof target !== 'string' || target.length === 0) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} entries must be non-empty strings`\n );\n }\n if (target === step.id) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} cannot reference itself`\n );\n }\n const targetStep = phaseStepIds.get(target);\n if (!targetStep) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} target '${target}' is not a step in this phase (same-phase only)`\n );\n }\n if (!targetStep.stateful) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} target '${target}' must be stateful`\n );\n }\n }\n}\n\nfunction validateBranchSet(storyboardId: string, phase: Storyboard['phases'][number]): void {\n if (phase.branch_set === undefined) return;\n const bs = phase.branch_set as unknown;\n if (!bs || typeof bs !== 'object') {\n throw new Error(`[${storyboardId}] phase '${phase.id}': branch_set must be an object with { id, semantics }`);\n }\n const { id, semantics } = bs as Record<string, unknown>;\n if (typeof id !== 'string' || id.length === 0) {\n throw new Error(`[${storyboardId}] phase '${phase.id}': branch_set.id must be a non-empty string`);\n }\n if (typeof semantics !== 'string' || semantics.length === 0) {\n throw new Error(`[${storyboardId}] phase '${phase.id}': branch_set.semantics must be a non-empty string`);\n }\n // Only `any_of` is defined in AdCP today (adcp#2646 lint rule 2 —\n // `at_least_n` and `all_of` are reserved but not defined). Reject unknown\n // values at parse rather than silently skipping grading at runtime, so\n // spec-drift typos fail loud instead of degrading to raw `failed` peers.\n if (!(BRANCH_SET_SEMANTICS as readonly string[]).includes(semantics)) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}': branch_set.semantics='${semantics}' is not supported (valid: ${BRANCH_SET_SEMANTICS.join(', ')})`\n );\n }\n // Schema constraint: every phase in a branch set MUST be optional. A\n // non-optional branch-set phase would fail the storyboard on any step\n // failure regardless of peer contribution, defeating the any_of gate.\n if (phase.optional !== true) {\n throw new Error(`[${storyboardId}] phase '${phase.id}': phases declaring branch_set must set 'optional: true'`);\n }\n}\n\n/**\n * Resolve the `contributes: true` boolean shorthand introduced alongside the\n * first-class `branch_set:` phase field (adcp-client#693, adcp#2646).\n *\n * Rules:\n * - `contributes: true` is legal only inside a phase that declares `branch_set:`.\n * - A step MUST NOT set both `contributes` and `contributes_to` (ambiguous).\n * - A string `contributes_to` inside a branch_set phase MUST equal `branch_set.id`\n * (otherwise the aggregation target drifts — same invariant the spec lint enforces).\n *\n * After resolution, `step.contributes_to` carries the flag name and `step.contributes`\n * is cleared, so the runner reads a single field regardless of authoring form.\n */\nfunction resolveContributesShorthand(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n const hasBoolean = step.contributes !== undefined;\n const hasString = step.contributes_to !== undefined;\n\n if (hasBoolean && hasString) {\n throw new Error(`[${storyboardId}] step '${step.id}' declares both 'contributes' and 'contributes_to' — pick one`);\n }\n\n if (hasBoolean) {\n if (step.contributes === true) {\n if (!phase.branch_set) {\n throw new Error(\n `[${storyboardId}] step '${step.id}': 'contributes: true' is only legal inside a phase that declares branch_set`\n );\n }\n step.contributes_to = phase.branch_set.id;\n }\n delete step.contributes;\n return;\n }\n\n if (hasString && phase.branch_set && step.contributes_to !== phase.branch_set.id) {\n throw new Error(\n `[${storyboardId}] step '${step.id}': contributes_to='${step.contributes_to}' must equal enclosing phase's branch_set.id='${phase.branch_set.id}'`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,gBAA6B;AAC7B,kBAAsB;AAEtB,yBAA+B;AAC/B,gCAAsD;AACtD,oBAAqC;AACrC,6BAAoC;AAO7B,MAAM,uBAAuB,CAAC,QAAQ;AAE7C,MAAM,0BAA0B,OAAO;AACvC,MAAM,0BAA0B,IAAI,OAAO,IAAI,uBAAuB,SAAS,uBAAuB,KAAK;AAC3G,MAAM,0BAA0B;AAGzB,SAAS,gBAAgB,aAAiC;AAC/D,QAAM,aAAS,mBAAM,WAAW;AAChC,MAAI,CAAC,QAAQ,MAAM,CAAC,QAAQ,QAAQ;AAClC,UAAM,IAAI,MAAM,+DAA+D;AAAA,EACjF;AACA,MAAI,OAAO,UAAU,eAAe,KAAK,QAAQ,gBAAgB,GAAG;AAClE,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,aAAW,SAAS,OAAO,QAAQ;AAIjC,QAAI,CAAC,MAAM,MAAO,OAAM,QAAQ,CAAC;AAEjC,eAAW,QAAQ,MAAM,OAAO;AAC9B,UAAI,CAAC,KAAK,gBAAiB;AAC3B,iBAAW,UAAU,KAAK,iBAAiB;AACzC,cAAM,MAAM;AACZ,YAAI,IAAI,QAAQ,CAAC,IAAI,KAAK;AACxB,iBAAO,MAAM,IAAI;AAA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WAAW,KAAK,EAAE;AAAA,QACpC;AAAA,MACF;AACA,WAAK,iBAAiB,MAAM,WAAW;AAAA,IACzC;AACA,WAAO,KAAK;AACZ;AAAA,EACF;AAEA,MAAI,aAAa,MAAM,cAAc,KAAK,mBAAmB,MAAM,WAAW,IAAI;AAChF,UAAM,IAAI;AAAA,MACR,IAAI,YAAY,WAAW,KAAK,EAAE,sBAAsB,KAAK,cAAc,iDAAiD,MAAM,WAAW,EAAE;AAAA,IACjJ;AAAA,EACF;AACF;","names":["prefix","validSemver"]}
@@ -3,6 +3,7 @@ import { parse } from "yaml";
3
3
  import { MUTATING_TASKS } from "../../utils/idempotency.mjs";
4
4
  import { validateFixtureResolutionDeclarations } from "./fixture-resolution.mjs";
5
5
  import { valid as validSemver } from "semver";
6
+ import { parsePhaseCondition } from "./phase-condition.mjs";
6
7
  const BRANCH_SET_SEMANTICS = ["any_of"];
7
8
  const IDENTIFIER_PATH_SEGMENT = String.raw`[A-Za-z_][A-Za-z0-9_-]*(?:\[\*\])*`;
8
9
  const IDENTIFIER_PATH_PATTERN = new RegExp(`^${IDENTIFIER_PATH_SEGMENT}(?:\\.${IDENTIFIER_PATH_SEGMENT})*$`);
@@ -42,6 +43,7 @@ function validateStoryboardShape(storyboard) {
42
43
  validateRequiredAnyOfTools(storyboard);
43
44
  validatePhaseDependsOn(storyboard);
44
45
  for (const phase of storyboard.phases) {
46
+ validatePhaseSkipIf(storyboard.id, phase);
45
47
  validateBranchSet(storyboard.id, phase);
46
48
  if (!phase.steps) continue;
47
49
  for (const step of phase.steps) {
@@ -56,6 +58,18 @@ function validateStoryboardShape(storyboard) {
56
58
  }
57
59
  }
58
60
  }
61
+ function validatePhaseSkipIf(storyboardId, phase) {
62
+ if (phase.skip_if === void 0) return;
63
+ if (typeof phase.skip_if !== "string") {
64
+ throw new Error(`[${storyboardId}] phase '${phase.id}': skip_if must be a string`);
65
+ }
66
+ try {
67
+ parsePhaseCondition(phase.skip_if);
68
+ } catch (error) {
69
+ const detail = error instanceof Error ? error.message : String(error);
70
+ throw new Error(`[${storyboardId}] phase '${phase.id}': ${detail}`);
71
+ }
72
+ }
59
73
  function validateRequiresAllCapabilities(storyboard) {
60
74
  const predicates = storyboard.requires_all_capabilities;
61
75
  if (predicates === void 0) return;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/testing/storyboard/loader.ts"],"sourcesContent":["/**\n * Storyboard YAML parser.\n *\n * Storyboards are pulled from the compliance cache populated by\n * `npm run sync-schemas`. See `./compliance.ts` for capability-driven\n * resolution and bundle loading.\n */\n\nimport { readFileSync } from 'fs';\nimport { parse } from 'yaml';\nimport type { Storyboard } from './types';\nimport { MUTATING_TASKS } from '../../utils/idempotency';\nimport { validateFixtureResolutionDeclarations } from './fixture-resolution';\nimport { valid as validSemver } from 'semver';\n\n/**\n * Supported `branch_set.semantics` values. Extend when AdCP adds `all_of`,\n * `at_least_n`, etc. Exported so the runner can enforce the same whitelist\n * on programmatically-constructed storyboards that bypass the YAML parser.\n */\nexport const BRANCH_SET_SEMANTICS = ['any_of'] as const;\n\nconst IDENTIFIER_PATH_SEGMENT = String.raw`[A-Za-z_][A-Za-z0-9_-]*(?:\\[\\*\\])*`;\nconst IDENTIFIER_PATH_PATTERN = new RegExp(`^${IDENTIFIER_PATH_SEGMENT}(?:\\\\.${IDENTIFIER_PATH_SEGMENT})*$`);\nconst CAPABILITY_PATH_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*(?:\\.[A-Za-z_][A-Za-z0-9_-]*)*$/;\n\n/** Parse a YAML string into a Storyboard. Throws if required fields are missing. */\nexport function parseStoryboard(yamlContent: string): Storyboard {\n const parsed = parse(yamlContent) as Storyboard;\n if (!parsed?.id || !parsed?.phases) {\n throw new Error('Invalid storyboard YAML: missing required fields (id, phases)');\n }\n if (Object.prototype.hasOwnProperty.call(parsed, 'compliance_dir')) {\n throw new Error(\n 'Invalid storyboard YAML: compliance_dir is loader-owned runtime provenance; select an external cache with runner options instead.'\n );\n }\n for (const phase of parsed.phases) {\n // Specialism YAMLs may declare a phase with no `steps:` — the steps are\n // synthesized at runtime from fixtures (see request-signing/synthesize.ts).\n // Treat missing steps as an empty list so the parser stays phase-agnostic.\n if (!phase.steps) phase.steps = [];\n // YAML uses `name:` for context outputs but our runtime expects `key:`.\n for (const step of phase.steps) {\n if (!step.context_outputs) continue;\n for (const output of step.context_outputs) {\n const raw = output as unknown as Record<string, unknown>;\n if (raw.name && !raw.key) {\n output.key = raw.name as string;\n }\n }\n }\n }\n validateStoryboardShape(parsed);\n return parsed;\n}\n\n/** Load and parse a single storyboard file. Useful for ad-hoc testing of in-development YAMLs. */\nexport function loadStoryboardFile(filePath: string): Storyboard {\n return parseStoryboard(readFileSync(filePath, 'utf-8'));\n}\n\n/**\n * Enforce authoring-time invariants on a Storyboard. Called by\n * `parseStoryboard`, and should also be called by any runner entry point\n * that accepts a programmatically-built `Storyboard` object so the same\n * loud-fail-on-drift guarantee holds regardless of how the storyboard was\n * constructed. Mutates only legacy shorthand fields (resolves\n * `contributes: true` to `contributes_to`) and is idempotent on\n * already-validated inputs.\n */\nexport function validateStoryboardShape(storyboard: Storyboard): void {\n validateRequires(storyboard);\n validateRequiresAllCapabilities(storyboard);\n validateFixtureResolutionDeclarations(storyboard);\n validateRequiredAnyOfTools(storyboard);\n validatePhaseDependsOn(storyboard);\n for (const phase of storyboard.phases) {\n validateBranchSet(storyboard.id, phase);\n if (!phase.steps) continue;\n for (const step of phase.steps) {\n resolveContributesShorthand(storyboard.id, phase, step);\n validateFixtureForMutatingStep(storyboard.id, phase, step);\n validateOmitFlagCoherence(storyboard.id, phase, step);\n validateContextOutputs(storyboard.id, phase, step);\n validateUpstreamAttestationMode(storyboard.id, phase, step);\n validateUpstreamIdentifierPaths(storyboard.id, phase, step);\n validateAdvisoryDeclarations(storyboard.id, phase, step);\n validatePeerSubstitutesFor(storyboard.id, phase, step);\n }\n }\n}\n\nfunction validateRequiresAllCapabilities(storyboard: Storyboard): void {\n const predicates = storyboard.requires_all_capabilities;\n if (predicates === undefined) return;\n if (!Array.isArray(predicates) || predicates.length < 2) {\n throw new Error(\n `[${storyboard.id}] requires_all_capabilities: must list at least two predicates; use requires_capability for one`\n );\n }\n for (let index = 0; index < predicates.length; index++) {\n const raw = predicates[index] as unknown;\n const prefix = `[${storyboard.id}] requires_all_capabilities[${index}]`;\n if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {\n throw new Error(`${prefix}: must be a capability predicate object`);\n }\n const predicate = raw as Record<string, unknown>;\n if (typeof predicate.path !== 'string' || predicate.path.trim().length === 0) {\n throw new Error(`${prefix}.path: must be a non-empty string`);\n }\n if (!CAPABILITY_PATH_PATTERN.test(predicate.path)) {\n throw new Error(`${prefix}.path: must be a canonical dotted capability path`);\n }\n const matcherKeys = ['equals', 'present', 'contains', 'not_contains'].filter(key =>\n Object.prototype.hasOwnProperty.call(predicate, key)\n );\n if (matcherKeys.length !== 1) {\n throw new Error(`${prefix}: must declare exactly one of equals, present, contains, or not_contains`);\n }\n const unknownKeys = Object.keys(predicate).filter(key => key !== 'path' && !matcherKeys.includes(key));\n if (unknownKeys.length > 0) {\n throw new Error(`${prefix}: unknown field${unknownKeys.length === 1 ? '' : 's'} ${unknownKeys.join(', ')}`);\n }\n if (matcherKeys[0] === 'present' && typeof predicate.present !== 'boolean') {\n throw new Error(`${prefix}.present: must be a boolean`);\n }\n if (\n matcherKeys[0] === 'equals' &&\n predicate.equals !== null &&\n !['boolean', 'string', 'number'].includes(typeof predicate.equals)\n ) {\n throw new Error(`${prefix}.equals: must be a boolean, string, number, or null`);\n }\n if (\n (matcherKeys[0] === 'contains' || matcherKeys[0] === 'not_contains') &&\n !isJsonCapabilityValue(predicate[matcherKeys[0]!])\n ) {\n throw new Error(`${prefix}.${matcherKeys[0]}: must be a JSON-compatible capability value`);\n }\n }\n}\n\nfunction isJsonCapabilityValue(value: unknown, seen = new Set<object>()): boolean {\n if (value === null || ['boolean', 'string'].includes(typeof value)) return true;\n if (typeof value === 'number') return Number.isFinite(value);\n if (typeof value !== 'object') return false;\n if (seen.has(value)) return false;\n seen.add(value);\n const valid = Array.isArray(value)\n ? value.every(entry => isJsonCapabilityValue(entry, seen))\n : Object.getPrototypeOf(value) === Object.prototype &&\n Object.values(value as Record<string, unknown>).every(entry => isJsonCapabilityValue(entry, seen));\n seen.delete(value);\n return valid;\n}\n\nfunction validateAdvisoryDeclarations(\n storyboardId: string,\n phase: { id?: string },\n step: { id?: string; validations?: any[] }\n): void {\n for (let index = 0; index < (step.validations ?? []).length; index++) {\n const validation = step.validations![index];\n if (\n validation?.severity !== undefined &&\n validation.severity !== 'required' &&\n validation.severity !== 'advisory'\n ) {\n const prefix = `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${index}]`;\n throw new Error(`${prefix}.severity: must be either \"required\" or \"advisory\"`);\n }\n if (validation?.severity !== 'advisory') continue;\n const prefix = `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${index}]`;\n const hasExpiry = validation.expires_after_version !== undefined;\n const hasPermanent = validation.permanent_advisory !== undefined;\n if (hasExpiry === hasPermanent) {\n throw new Error(\n `${prefix}: severity \"advisory\" must declare exactly one of expires_after_version or permanent_advisory`\n );\n }\n if (\n hasExpiry &&\n (typeof validation.expires_after_version !== 'string' || !validSemver(validation.expires_after_version))\n ) {\n throw new Error(`${prefix}.expires_after_version: must be a valid semver string`);\n }\n if (\n hasPermanent &&\n (typeof validation.permanent_advisory !== 'object' ||\n validation.permanent_advisory === null ||\n typeof validation.permanent_advisory.reason !== 'string' ||\n validation.permanent_advisory.reason.trim().length === 0)\n ) {\n throw new Error(`${prefix}.permanent_advisory.reason: must be a non-empty string`);\n }\n }\n}\n\nfunction validateUpstreamAttestationMode(\n storyboardId: string,\n phase: { id?: string },\n step: { id?: string; validations?: any[] }\n): void {\n const validations = step.validations ?? [];\n for (let validationIndex = 0; validationIndex < validations.length; validationIndex++) {\n const validation = validations[validationIndex];\n if (validation?.check !== 'upstream_traffic') continue;\n const mode = validation.preferred_attestation_mode;\n if (mode !== undefined && mode !== 'raw' && mode !== 'digest') {\n throw new Error(\n `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${validationIndex}].preferred_attestation_mode: must be \"raw\" or \"digest\"`\n );\n }\n }\n}\n\nfunction validateUpstreamIdentifierPaths(\n storyboardId: string,\n phase: { id?: string },\n step: { id?: string; validations?: any[] }\n): void {\n const validations = step.validations ?? [];\n for (let validationIndex = 0; validationIndex < validations.length; validationIndex++) {\n const validation = validations[validationIndex];\n if (validation?.check !== 'upstream_traffic' || validation.identifier_paths === undefined) continue;\n if (!Array.isArray(validation.identifier_paths)) {\n throw new Error(\n `[${storyboardId}] ${phase.id ?? '?'}.${\n step.id ?? '?'\n }.validations[${validationIndex}].identifier_paths: must be an array of request-payload paths`\n );\n }\n for (let pathIndex = 0; pathIndex < validation.identifier_paths.length; pathIndex++) {\n const path = validation.identifier_paths[pathIndex];\n if (typeof path !== 'string' || path.length === 0) {\n throw new Error(\n `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${validationIndex}].identifier_paths[${pathIndex}]: must be a non-empty string`\n );\n }\n const pathErrorPrefix = `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${validationIndex}].identifier_paths[${pathIndex}]`;\n let firstSegment: string;\n try {\n const validated = validateIdentifierPathSyntax(path);\n firstSegment = validated.firstSegment;\n } catch {\n throw new Error(\n `${pathErrorPrefix}: \"${path}\" is unsupported; identifier_paths resolve only against the request payload or sample_request using dotted paths with [*] array selectors`\n );\n }\n const root = firstSegment.toLowerCase();\n if (root === 'request' || root === 'response' || root === 'context') {\n throw new Error(\n `${pathErrorPrefix}: \"${path}\" is unsupported; identifier_paths resolve only against the request payload or sample_request`\n );\n }\n }\n }\n}\n\nfunction validateIdentifierPathSyntax(path: string): { normalized: string; firstSegment: string } {\n const trimmed = path.trim();\n const normalized = trimmed.startsWith('$.') ? trimmed.slice(2) : trimmed;\n if (!IDENTIFIER_PATH_PATTERN.test(normalized)) {\n throw new Error('unsupported identifier path syntax');\n }\n return { normalized, firstSegment: normalized.split(/[.[\\]]/, 1)[0] ?? '' };\n}\n\nfunction validateRequiredAnyOfTools(storyboard: Storyboard): void {\n if (storyboard.required_any_of_tools === undefined) return;\n if (!Array.isArray(storyboard.required_any_of_tools)) {\n throw new Error(`[${storyboard.id}] required_any_of_tools: must be an array of tool-family objects`);\n }\n if (storyboard.required_any_of_tools.length === 0) {\n throw new Error(`[${storyboard.id}] required_any_of_tools: [] is not allowed — omit the field to use no gate`);\n }\n for (let i = 0; i < storyboard.required_any_of_tools.length; i++) {\n const family = storyboard.required_any_of_tools[i] as unknown;\n if (family === null || typeof family !== 'object' || Array.isArray(family)) {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}]: must be an object`);\n }\n const { tools, rationale } = family as { tools?: unknown; rationale?: unknown };\n if (!Array.isArray(tools) || tools.length < 2) {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}].tools: must list at least two tool names`);\n }\n for (const tool of tools) {\n if (typeof tool !== 'string' || tool.length === 0) {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}].tools: entries must be non-empty strings`);\n }\n }\n if (rationale !== undefined && typeof rationale !== 'string') {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}].rationale: must be a string`);\n }\n }\n}\n\n/**\n * Authoring-time validation for `phase.depends_on` (#1161). Each entry\n * must reference a phase declared earlier in the storyboard. Forward\n * references and self-references fail loud at parse time so authoring\n * mistakes (typos, reorderings) don't degrade silently into \"phase\n * always runs\" / \"phase always cascades.\"\n *\n * Rules:\n * - Empty list (`depends_on: []`) is legal — it declares an\n * independent phase. No further validation needed.\n * - Each non-empty entry must be a non-empty string.\n * - Each entry must reference a phase that appears EARLIER in the\n * `storyboard.phases[]` array (forward references are rejected).\n * - A phase cannot depend on itself.\n */\nfunction validatePhaseDependsOn(storyboard: Storyboard): void {\n const phaseIdsSeen = new Set<string>();\n for (const phase of storyboard.phases) {\n if (phase.depends_on !== undefined) {\n if (!Array.isArray(phase.depends_on)) {\n throw new Error(`[${storyboard.id}] phase '${phase.id}': depends_on must be an array of phase ids`);\n }\n for (const dep of phase.depends_on) {\n if (typeof dep !== 'string' || dep.length === 0) {\n throw new Error(`[${storyboard.id}] phase '${phase.id}': depends_on entries must be non-empty strings`);\n }\n if (dep === phase.id) {\n throw new Error(`[${storyboard.id}] phase '${phase.id}': depends_on cannot reference itself`);\n }\n if (!phaseIdsSeen.has(dep)) {\n throw new Error(\n `[${storyboard.id}] phase '${phase.id}': depends_on '${dep}' is not a phase declared earlier in this storyboard (forward and unknown references are rejected)`\n );\n }\n }\n }\n phaseIdsSeen.add(phase.id);\n }\n}\n\n/**\n * Authoring-time validation for `Storyboard.requires` (#1626). The field is\n * an array of non-empty requirement names:\n *\n * - `requires: []` is rejected — an empty array reads as \"no\n * requirements,\" which is the same as omitting the field; failing\n * load forces the author to omit it explicitly.\n * - Each entry must be a non-empty string.\n *\n * Unknown string values are allowed for forward compatibility. Runners that\n * don't know how to satisfy a future requirement skip at runtime with\n * `skip_reason: 'requirement_unmet'` and the authored value in\n * `skip.requirement`.\n */\nfunction validateRequires(storyboard: Storyboard): void {\n if (storyboard.requires === undefined) return;\n if (!Array.isArray(storyboard.requires)) {\n throw new Error(\n `[${storyboard.id}] requires: must be an array of requirement names (got ${typeof storyboard.requires})`\n );\n }\n if (storyboard.requires.length === 0) {\n throw new Error(`[${storyboard.id}] requires: [] is not allowed — omit the field to use the default ([real_wire])`);\n }\n for (let i = 0; i < storyboard.requires.length; i++) {\n const name = storyboard.requires[i];\n if (typeof name !== 'string' || name.length === 0) {\n throw new Error(`[${storyboard.id}] requires[${i}]: entries must be non-empty strings`);\n }\n }\n}\n\n/**\n * Issue #820: mutating tasks (per {@link MUTATING_TASKS}) must have a\n * `sample_request` authored. The fixture is authoritative at run time —\n * there's no sane default payload for a write, and silently fabricating\n * one was the bug factory that produced #780 / #792 / #793 / #802 / #805.\n *\n * Error messages point at the task name, the step id, the storyboard, and\n * suggest the concrete author action.\n *\n * Opt-out: steps with `expect_error: true` that deliberately exercise\n * missing-fixture / malformed-payload seller behavior skip this check —\n * the author is signaling the payload is the test condition.\n *\n * Synthesized phases (`request-signing/synthesize.ts`, controller seeding)\n * start with `phase.steps = []` in YAML and the loader doesn't see the\n * runtime-generated steps, so those paths are not affected.\n */\nfunction validateFixtureForMutatingStep(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n if (!MUTATING_TASKS.has(step.task)) return;\n if (step.sample_request !== undefined) return;\n if (step.expect_error === true) return;\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}' (task=${step.task}): ` +\n `mutating tasks require a sample_request fixture — the runner no longer fabricates ` +\n `write payloads. Author sample_request in the step or, for intentionally malformed ` +\n `payloads, set expect_error: true.`\n );\n}\n\n/**\n * `omit_account: true` must be paired with `expect_error: true`.\n *\n * An accountless `create_media_buy` will always be rejected by a spec-compliant\n * seller; a step that sets `omit_account` without `expect_error` will be graded\n * as a failure (not a controlled negative test), producing a misleading\n * compliance result. Fail loud at parse time so the author sees the problem\n * during storyboard load, not at run time.\n */\nfunction validateOmitFlagCoherence(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n if (step.omit_account && step.expect_error !== true) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ` +\n `omit_account: true requires expect_error: true — an accountless ` +\n `create_media_buy will always be rejected by a spec-compliant seller.`\n );\n }\n}\n\n/**\n * Each `context_outputs` entry must declare exactly one source: either\n * `path` (extract from response) or `generate` (mint at run time). An entry\n * with neither is a silent no-op; one with both would silently pick `generate`\n * and ignore `path`. Both are authoring foot-guns that should fail loud.\n */\nfunction validateContextOutputs(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n if (!step.context_outputs?.length) return;\n for (const output of step.context_outputs) {\n const hasPath = output.path !== undefined;\n const hasGenerate = output.generate !== undefined;\n if (!hasPath && !hasGenerate) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': context_outputs entry ` +\n `'${output.key}' must set exactly one of 'path' or 'generate'.`\n );\n }\n if (hasPath && hasGenerate) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': context_outputs entry ` +\n `'${output.key}' sets both 'path' and 'generate' — they are mutually exclusive.`\n );\n }\n // Validate generator name. The runtime resolver also checks but the loader\n // catches typos at storyboard-load time so authors see the failure on\n // build, not on the first run.\n if (hasGenerate && output.generate !== 'uuid_v4' && output.generate !== 'opaque_id') {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': context_outputs entry ` +\n `'${output.key}' has unknown generate value '${output.generate}'. ` +\n `Supported: 'uuid_v4', 'opaque_id'.`\n );\n }\n }\n}\n\n/**\n * Authoring-time validation for `provides_state_for` (the AdCP 3.0.3 spec\n * field — adcp#3734) and the legacy `peer_substitutes_for` synonym. The\n * runner treats the field as same-phase-only and substitution-only-when-\n * stateful; surface those constraints at parse time so storyboard authors\n * see typos and cross-phase references on build, not as a silent no-rescue\n * at run time.\n *\n * Both field names parse to the same canonical normalized form on the step\n * object (the spec name `provides_state_for` is preferred when both are\n * declared). The deprecation alias is documented in `types.ts`.\n *\n * Rules:\n * - Each target must reference a step that exists in the same phase.\n * - A step cannot substitute for itself.\n * - The substitute step itself must be `stateful: true` — non-stateful\n * passes don't establish state per the cascade contract.\n * - The target step must be `stateful: true` — non-stateful targets\n * don't participate in cascade gating, so a substitution declaration\n * would be a no-op.\n * - When both fields are declared on the same step, they must match\n * element-for-element (the deprecation contract is \"synonym for\", not\n * \"additive with\").\n */\nfunction validatePeerSubstitutesFor(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n const newField = step.provides_state_for;\n const legacyField = step.peer_substitutes_for;\n if (newField === undefined && legacyField === undefined) return;\n\n if (newField !== undefined && legacyField !== undefined) {\n // Order-sensitive equality: `[A, B]` vs `[B, A]` would throw despite being\n // semantically equivalent. Authors mid-migration should write the same list\n // in both fields; the deprecation alias is a literal synonym, not a\n // same-set restatement.\n const a = JSON.stringify(Array.isArray(newField) ? newField : [newField]);\n const b = JSON.stringify(Array.isArray(legacyField) ? legacyField : [legacyField]);\n if (a !== b) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': both provides_state_for and ` +\n `peer_substitutes_for declared with different values — pick one (provides_state_for is the ` +\n `spec field; peer_substitutes_for is a deprecated synonym)`\n );\n }\n }\n\n // Normalize onto provides_state_for so the runner can read a single field.\n // peer_substitutes_for stays for back-compat with any consumer code that\n // already reads it.\n if (newField === undefined && legacyField !== undefined) {\n step.provides_state_for = legacyField;\n } else if (newField !== undefined && legacyField === undefined) {\n step.peer_substitutes_for = newField;\n }\n\n const sourceFieldName = newField !== undefined ? 'provides_state_for' : 'peer_substitutes_for';\n const declared = step.provides_state_for!;\n const targets = Array.isArray(declared) ? declared : [declared];\n if (!step.stateful) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} is only legal on stateful steps`\n );\n }\n const phaseStepIds = new Map(phase.steps.map(s => [s.id, s]));\n for (const target of targets) {\n if (typeof target !== 'string' || target.length === 0) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} entries must be non-empty strings`\n );\n }\n if (target === step.id) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} cannot reference itself`\n );\n }\n const targetStep = phaseStepIds.get(target);\n if (!targetStep) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} target '${target}' is not a step in this phase (same-phase only)`\n );\n }\n if (!targetStep.stateful) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} target '${target}' must be stateful`\n );\n }\n }\n}\n\nfunction validateBranchSet(storyboardId: string, phase: Storyboard['phases'][number]): void {\n if (phase.branch_set === undefined) return;\n const bs = phase.branch_set as unknown;\n if (!bs || typeof bs !== 'object') {\n throw new Error(`[${storyboardId}] phase '${phase.id}': branch_set must be an object with { id, semantics }`);\n }\n const { id, semantics } = bs as Record<string, unknown>;\n if (typeof id !== 'string' || id.length === 0) {\n throw new Error(`[${storyboardId}] phase '${phase.id}': branch_set.id must be a non-empty string`);\n }\n if (typeof semantics !== 'string' || semantics.length === 0) {\n throw new Error(`[${storyboardId}] phase '${phase.id}': branch_set.semantics must be a non-empty string`);\n }\n // Only `any_of` is defined in AdCP today (adcp#2646 lint rule 2 —\n // `at_least_n` and `all_of` are reserved but not defined). Reject unknown\n // values at parse rather than silently skipping grading at runtime, so\n // spec-drift typos fail loud instead of degrading to raw `failed` peers.\n if (!(BRANCH_SET_SEMANTICS as readonly string[]).includes(semantics)) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}': branch_set.semantics='${semantics}' is not supported (valid: ${BRANCH_SET_SEMANTICS.join(', ')})`\n );\n }\n // Schema constraint: every phase in a branch set MUST be optional. A\n // non-optional branch-set phase would fail the storyboard on any step\n // failure regardless of peer contribution, defeating the any_of gate.\n if (phase.optional !== true) {\n throw new Error(`[${storyboardId}] phase '${phase.id}': phases declaring branch_set must set 'optional: true'`);\n }\n}\n\n/**\n * Resolve the `contributes: true` boolean shorthand introduced alongside the\n * first-class `branch_set:` phase field (adcp-client#693, adcp#2646).\n *\n * Rules:\n * - `contributes: true` is legal only inside a phase that declares `branch_set:`.\n * - A step MUST NOT set both `contributes` and `contributes_to` (ambiguous).\n * - A string `contributes_to` inside a branch_set phase MUST equal `branch_set.id`\n * (otherwise the aggregation target drifts — same invariant the spec lint enforces).\n *\n * After resolution, `step.contributes_to` carries the flag name and `step.contributes`\n * is cleared, so the runner reads a single field regardless of authoring form.\n */\nfunction resolveContributesShorthand(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n const hasBoolean = step.contributes !== undefined;\n const hasString = step.contributes_to !== undefined;\n\n if (hasBoolean && hasString) {\n throw new Error(`[${storyboardId}] step '${step.id}' declares both 'contributes' and 'contributes_to' — pick one`);\n }\n\n if (hasBoolean) {\n if (step.contributes === true) {\n if (!phase.branch_set) {\n throw new Error(\n `[${storyboardId}] step '${step.id}': 'contributes: true' is only legal inside a phase that declares branch_set`\n );\n }\n step.contributes_to = phase.branch_set.id;\n }\n delete step.contributes;\n return;\n }\n\n if (hasString && phase.branch_set && step.contributes_to !== phase.branch_set.id) {\n throw new Error(\n `[${storyboardId}] step '${step.id}': contributes_to='${step.contributes_to}' must equal enclosing phase's branch_set.id='${phase.branch_set.id}'`\n );\n }\n}\n"],"mappings":"AAQA,SAAS,oBAAoB;AAC7B,SAAS,aAAa;AAEtB,SAAS,sBAAsB;AAC/B,SAAS,6CAA6C;AACtD,SAAS,SAAS,mBAAmB;AAO9B,MAAM,uBAAuB,CAAC,QAAQ;AAE7C,MAAM,0BAA0B,OAAO;AACvC,MAAM,0BAA0B,IAAI,OAAO,IAAI,uBAAuB,SAAS,uBAAuB,KAAK;AAC3G,MAAM,0BAA0B;AAGzB,SAAS,gBAAgB,aAAiC;AAC/D,QAAM,SAAS,MAAM,WAAW;AAChC,MAAI,CAAC,QAAQ,MAAM,CAAC,QAAQ,QAAQ;AAClC,UAAM,IAAI,MAAM,+DAA+D;AAAA,EACjF;AACA,MAAI,OAAO,UAAU,eAAe,KAAK,QAAQ,gBAAgB,GAAG;AAClE,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,aAAW,SAAS,OAAO,QAAQ;AAIjC,QAAI,CAAC,MAAM,MAAO,OAAM,QAAQ,CAAC;AAEjC,eAAW,QAAQ,MAAM,OAAO;AAC9B,UAAI,CAAC,KAAK,gBAAiB;AAC3B,iBAAW,UAAU,KAAK,iBAAiB;AACzC,c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sources":["../../../../src/lib/testing/storyboard/loader.ts"],"sourcesContent":["/**\n * Storyboard YAML parser.\n *\n * Storyboards are pulled from the compliance cache populated by\n * `npm run sync-schemas`. See `./compliance.ts` for capability-driven\n * resolution and bundle loading.\n */\n\nimport { readFileSync } from 'fs';\nimport { parse } from 'yaml';\nimport type { Storyboard } from './types';\nimport { MUTATING_TASKS } from '../../utils/idempotency';\nimport { validateFixtureResolutionDeclarations } from './fixture-resolution';\nimport { valid as validSemver } from 'semver';\nimport { parsePhaseCondition } from './phase-condition';\n\n/**\n * Supported `branch_set.semantics` values. Extend when AdCP adds `all_of`,\n * `at_least_n`, etc. Exported so the runner can enforce the same whitelist\n * on programmatically-constructed storyboards that bypass the YAML parser.\n */\nexport const BRANCH_SET_SEMANTICS = ['any_of'] as const;\n\nconst IDENTIFIER_PATH_SEGMENT = String.raw`[A-Za-z_][A-Za-z0-9_-]*(?:\\[\\*\\])*`;\nconst IDENTIFIER_PATH_PATTERN = new RegExp(`^${IDENTIFIER_PATH_SEGMENT}(?:\\\\.${IDENTIFIER_PATH_SEGMENT})*$`);\nconst CAPABILITY_PATH_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*(?:\\.[A-Za-z_][A-Za-z0-9_-]*)*$/;\n\n/** Parse a YAML string into a Storyboard. Throws if required fields are missing. */\nexport function parseStoryboard(yamlContent: string): Storyboard {\n const parsed = parse(yamlContent) as Storyboard;\n if (!parsed?.id || !parsed?.phases) {\n throw new Error('Invalid storyboard YAML: missing required fields (id, phases)');\n }\n if (Object.prototype.hasOwnProperty.call(parsed, 'compliance_dir')) {\n throw new Error(\n 'Invalid storyboard YAML: compliance_dir is loader-owned runtime provenance; select an external cache with runner options instead.'\n );\n }\n for (const phase of parsed.phases) {\n // Specialism YAMLs may declare a phase with no `steps:` — the steps are\n // synthesized at runtime from fixtures (see request-signing/synthesize.ts).\n // Treat missing steps as an empty list so the parser stays phase-agnostic.\n if (!phase.steps) phase.steps = [];\n // YAML uses `name:` for context outputs but our runtime expects `key:`.\n for (const step of phase.steps) {\n if (!step.context_outputs) continue;\n for (const output of step.context_outputs) {\n const raw = output as unknown as Record<string, unknown>;\n if (raw.name && !raw.key) {\n output.key = raw.name as string;\n }\n }\n }\n }\n validateStoryboardShape(parsed);\n return parsed;\n}\n\n/** Load and parse a single storyboard file. Useful for ad-hoc testing of in-development YAMLs. */\nexport function loadStoryboardFile(filePath: string): Storyboard {\n return parseStoryboard(readFileSync(filePath, 'utf-8'));\n}\n\n/**\n * Enforce authoring-time invariants on a Storyboard. Called by\n * `parseStoryboard`, and should also be called by any runner entry point\n * that accepts a programmatically-built `Storyboard` object so the same\n * loud-fail-on-drift guarantee holds regardless of how the storyboard was\n * constructed. Mutates only legacy shorthand fields (resolves\n * `contributes: true` to `contributes_to`) and is idempotent on\n * already-validated inputs.\n */\nexport function validateStoryboardShape(storyboard: Storyboard): void {\n validateRequires(storyboard);\n validateRequiresAllCapabilities(storyboard);\n validateFixtureResolutionDeclarations(storyboard);\n validateRequiredAnyOfTools(storyboard);\n validatePhaseDependsOn(storyboard);\n for (const phase of storyboard.phases) {\n validatePhaseSkipIf(storyboard.id, phase);\n validateBranchSet(storyboard.id, phase);\n if (!phase.steps) continue;\n for (const step of phase.steps) {\n resolveContributesShorthand(storyboard.id, phase, step);\n validateFixtureForMutatingStep(storyboard.id, phase, step);\n validateOmitFlagCoherence(storyboard.id, phase, step);\n validateContextOutputs(storyboard.id, phase, step);\n validateUpstreamAttestationMode(storyboard.id, phase, step);\n validateUpstreamIdentifierPaths(storyboard.id, phase, step);\n validateAdvisoryDeclarations(storyboard.id, phase, step);\n validatePeerSubstitutesFor(storyboard.id, phase, step);\n }\n }\n}\n\nfunction validatePhaseSkipIf(storyboardId: string, phase: Storyboard['phases'][number]): void {\n if (phase.skip_if === undefined) return;\n if (typeof phase.skip_if !== 'string') {\n throw new Error(`[${storyboardId}] phase '${phase.id}': skip_if must be a string`);\n }\n try {\n parsePhaseCondition(phase.skip_if);\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error);\n throw new Error(`[${storyboardId}] phase '${phase.id}': ${detail}`);\n }\n}\n\nfunction validateRequiresAllCapabilities(storyboard: Storyboard): void {\n const predicates = storyboard.requires_all_capabilities;\n if (predicates === undefined) return;\n if (!Array.isArray(predicates) || predicates.length < 2) {\n throw new Error(\n `[${storyboard.id}] requires_all_capabilities: must list at least two predicates; use requires_capability for one`\n );\n }\n for (let index = 0; index < predicates.length; index++) {\n const raw = predicates[index] as unknown;\n const prefix = `[${storyboard.id}] requires_all_capabilities[${index}]`;\n if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {\n throw new Error(`${prefix}: must be a capability predicate object`);\n }\n const predicate = raw as Record<string, unknown>;\n if (typeof predicate.path !== 'string' || predicate.path.trim().length === 0) {\n throw new Error(`${prefix}.path: must be a non-empty string`);\n }\n if (!CAPABILITY_PATH_PATTERN.test(predicate.path)) {\n throw new Error(`${prefix}.path: must be a canonical dotted capability path`);\n }\n const matcherKeys = ['equals', 'present', 'contains', 'not_contains'].filter(key =>\n Object.prototype.hasOwnProperty.call(predicate, key)\n );\n if (matcherKeys.length !== 1) {\n throw new Error(`${prefix}: must declare exactly one of equals, present, contains, or not_contains`);\n }\n const unknownKeys = Object.keys(predicate).filter(key => key !== 'path' && !matcherKeys.includes(key));\n if (unknownKeys.length > 0) {\n throw new Error(`${prefix}: unknown field${unknownKeys.length === 1 ? '' : 's'} ${unknownKeys.join(', ')}`);\n }\n if (matcherKeys[0] === 'present' && typeof predicate.present !== 'boolean') {\n throw new Error(`${prefix}.present: must be a boolean`);\n }\n if (\n matcherKeys[0] === 'equals' &&\n predicate.equals !== null &&\n !['boolean', 'string', 'number'].includes(typeof predicate.equals)\n ) {\n throw new Error(`${prefix}.equals: must be a boolean, string, number, or null`);\n }\n if (\n (matcherKeys[0] === 'contains' || matcherKeys[0] === 'not_contains') &&\n !isJsonCapabilityValue(predicate[matcherKeys[0]!])\n ) {\n throw new Error(`${prefix}.${matcherKeys[0]}: must be a JSON-compatible capability value`);\n }\n }\n}\n\nfunction isJsonCapabilityValue(value: unknown, seen = new Set<object>()): boolean {\n if (value === null || ['boolean', 'string'].includes(typeof value)) return true;\n if (typeof value === 'number') return Number.isFinite(value);\n if (typeof value !== 'object') return false;\n if (seen.has(value)) return false;\n seen.add(value);\n const valid = Array.isArray(value)\n ? value.every(entry => isJsonCapabilityValue(entry, seen))\n : Object.getPrototypeOf(value) === Object.prototype &&\n Object.values(value as Record<string, unknown>).every(entry => isJsonCapabilityValue(entry, seen));\n seen.delete(value);\n return valid;\n}\n\nfunction validateAdvisoryDeclarations(\n storyboardId: string,\n phase: { id?: string },\n step: { id?: string; validations?: any[] }\n): void {\n for (let index = 0; index < (step.validations ?? []).length; index++) {\n const validation = step.validations![index];\n if (\n validation?.severity !== undefined &&\n validation.severity !== 'required' &&\n validation.severity !== 'advisory'\n ) {\n const prefix = `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${index}]`;\n throw new Error(`${prefix}.severity: must be either \"required\" or \"advisory\"`);\n }\n if (validation?.severity !== 'advisory') continue;\n const prefix = `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${index}]`;\n const hasExpiry = validation.expires_after_version !== undefined;\n const hasPermanent = validation.permanent_advisory !== undefined;\n if (hasExpiry === hasPermanent) {\n throw new Error(\n `${prefix}: severity \"advisory\" must declare exactly one of expires_after_version or permanent_advisory`\n );\n }\n if (\n hasExpiry &&\n (typeof validation.expires_after_version !== 'string' || !validSemver(validation.expires_after_version))\n ) {\n throw new Error(`${prefix}.expires_after_version: must be a valid semver string`);\n }\n if (\n hasPermanent &&\n (typeof validation.permanent_advisory !== 'object' ||\n validation.permanent_advisory === null ||\n typeof validation.permanent_advisory.reason !== 'string' ||\n validation.permanent_advisory.reason.trim().length === 0)\n ) {\n throw new Error(`${prefix}.permanent_advisory.reason: must be a non-empty string`);\n }\n }\n}\n\nfunction validateUpstreamAttestationMode(\n storyboardId: string,\n phase: { id?: string },\n step: { id?: string; validations?: any[] }\n): void {\n const validations = step.validations ?? [];\n for (let validationIndex = 0; validationIndex < validations.length; validationIndex++) {\n const validation = validations[validationIndex];\n if (validation?.check !== 'upstream_traffic') continue;\n const mode = validation.preferred_attestation_mode;\n if (mode !== undefined && mode !== 'raw' && mode !== 'digest') {\n throw new Error(\n `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${validationIndex}].preferred_attestation_mode: must be \"raw\" or \"digest\"`\n );\n }\n }\n}\n\nfunction validateUpstreamIdentifierPaths(\n storyboardId: string,\n phase: { id?: string },\n step: { id?: string; validations?: any[] }\n): void {\n const validations = step.validations ?? [];\n for (let validationIndex = 0; validationIndex < validations.length; validationIndex++) {\n const validation = validations[validationIndex];\n if (validation?.check !== 'upstream_traffic' || validation.identifier_paths === undefined) continue;\n if (!Array.isArray(validation.identifier_paths)) {\n throw new Error(\n `[${storyboardId}] ${phase.id ?? '?'}.${\n step.id ?? '?'\n }.validations[${validationIndex}].identifier_paths: must be an array of request-payload paths`\n );\n }\n for (let pathIndex = 0; pathIndex < validation.identifier_paths.length; pathIndex++) {\n const path = validation.identifier_paths[pathIndex];\n if (typeof path !== 'string' || path.length === 0) {\n throw new Error(\n `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${validationIndex}].identifier_paths[${pathIndex}]: must be a non-empty string`\n );\n }\n const pathErrorPrefix = `[${storyboardId}] ${phase.id ?? '?'}.${step.id ?? '?'}.validations[${validationIndex}].identifier_paths[${pathIndex}]`;\n let firstSegment: string;\n try {\n const validated = validateIdentifierPathSyntax(path);\n firstSegment = validated.firstSegment;\n } catch {\n throw new Error(\n `${pathErrorPrefix}: \"${path}\" is unsupported; identifier_paths resolve only against the request payload or sample_request using dotted paths with [*] array selectors`\n );\n }\n const root = firstSegment.toLowerCase();\n if (root === 'request' || root === 'response' || root === 'context') {\n throw new Error(\n `${pathErrorPrefix}: \"${path}\" is unsupported; identifier_paths resolve only against the request payload or sample_request`\n );\n }\n }\n }\n}\n\nfunction validateIdentifierPathSyntax(path: string): { normalized: string; firstSegment: string } {\n const trimmed = path.trim();\n const normalized = trimmed.startsWith('$.') ? trimmed.slice(2) : trimmed;\n if (!IDENTIFIER_PATH_PATTERN.test(normalized)) {\n throw new Error('unsupported identifier path syntax');\n }\n return { normalized, firstSegment: normalized.split(/[.[\\]]/, 1)[0] ?? '' };\n}\n\nfunction validateRequiredAnyOfTools(storyboard: Storyboard): void {\n if (storyboard.required_any_of_tools === undefined) return;\n if (!Array.isArray(storyboard.required_any_of_tools)) {\n throw new Error(`[${storyboard.id}] required_any_of_tools: must be an array of tool-family objects`);\n }\n if (storyboard.required_any_of_tools.length === 0) {\n throw new Error(`[${storyboard.id}] required_any_of_tools: [] is not allowed — omit the field to use no gate`);\n }\n for (let i = 0; i < storyboard.required_any_of_tools.length; i++) {\n const family = storyboard.required_any_of_tools[i] as unknown;\n if (family === null || typeof family !== 'object' || Array.isArray(family)) {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}]: must be an object`);\n }\n const { tools, rationale } = family as { tools?: unknown; rationale?: unknown };\n if (!Array.isArray(tools) || tools.length < 2) {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}].tools: must list at least two tool names`);\n }\n for (const tool of tools) {\n if (typeof tool !== 'string' || tool.length === 0) {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}].tools: entries must be non-empty strings`);\n }\n }\n if (rationale !== undefined && typeof rationale !== 'string') {\n throw new Error(`[${storyboard.id}] required_any_of_tools[${i}].rationale: must be a string`);\n }\n }\n}\n\n/**\n * Authoring-time validation for `phase.depends_on` (#1161). Each entry\n * must reference a phase declared earlier in the storyboard. Forward\n * references and self-references fail loud at parse time so authoring\n * mistakes (typos, reorderings) don't degrade silently into \"phase\n * always runs\" / \"phase always cascades.\"\n *\n * Rules:\n * - Empty list (`depends_on: []`) is legal — it declares an\n * independent phase. No further validation needed.\n * - Each non-empty entry must be a non-empty string.\n * - Each entry must reference a phase that appears EARLIER in the\n * `storyboard.phases[]` array (forward references are rejected).\n * - A phase cannot depend on itself.\n */\nfunction validatePhaseDependsOn(storyboard: Storyboard): void {\n const phaseIdsSeen = new Set<string>();\n for (const phase of storyboard.phases) {\n if (phase.depends_on !== undefined) {\n if (!Array.isArray(phase.depends_on)) {\n throw new Error(`[${storyboard.id}] phase '${phase.id}': depends_on must be an array of phase ids`);\n }\n for (const dep of phase.depends_on) {\n if (typeof dep !== 'string' || dep.length === 0) {\n throw new Error(`[${storyboard.id}] phase '${phase.id}': depends_on entries must be non-empty strings`);\n }\n if (dep === phase.id) {\n throw new Error(`[${storyboard.id}] phase '${phase.id}': depends_on cannot reference itself`);\n }\n if (!phaseIdsSeen.has(dep)) {\n throw new Error(\n `[${storyboard.id}] phase '${phase.id}': depends_on '${dep}' is not a phase declared earlier in this storyboard (forward and unknown references are rejected)`\n );\n }\n }\n }\n phaseIdsSeen.add(phase.id);\n }\n}\n\n/**\n * Authoring-time validation for `Storyboard.requires` (#1626). The field is\n * an array of non-empty requirement names:\n *\n * - `requires: []` is rejected — an empty array reads as \"no\n * requirements,\" which is the same as omitting the field; failing\n * load forces the author to omit it explicitly.\n * - Each entry must be a non-empty string.\n *\n * Unknown string values are allowed for forward compatibility. Runners that\n * don't know how to satisfy a future requirement skip at runtime with\n * `skip_reason: 'requirement_unmet'` and the authored value in\n * `skip.requirement`.\n */\nfunction validateRequires(storyboard: Storyboard): void {\n if (storyboard.requires === undefined) return;\n if (!Array.isArray(storyboard.requires)) {\n throw new Error(\n `[${storyboard.id}] requires: must be an array of requirement names (got ${typeof storyboard.requires})`\n );\n }\n if (storyboard.requires.length === 0) {\n throw new Error(`[${storyboard.id}] requires: [] is not allowed — omit the field to use the default ([real_wire])`);\n }\n for (let i = 0; i < storyboard.requires.length; i++) {\n const name = storyboard.requires[i];\n if (typeof name !== 'string' || name.length === 0) {\n throw new Error(`[${storyboard.id}] requires[${i}]: entries must be non-empty strings`);\n }\n }\n}\n\n/**\n * Issue #820: mutating tasks (per {@link MUTATING_TASKS}) must have a\n * `sample_request` authored. The fixture is authoritative at run time —\n * there's no sane default payload for a write, and silently fabricating\n * one was the bug factory that produced #780 / #792 / #793 / #802 / #805.\n *\n * Error messages point at the task name, the step id, the storyboard, and\n * suggest the concrete author action.\n *\n * Opt-out: steps with `expect_error: true` that deliberately exercise\n * missing-fixture / malformed-payload seller behavior skip this check —\n * the author is signaling the payload is the test condition.\n *\n * Synthesized phases (`request-signing/synthesize.ts`, controller seeding)\n * start with `phase.steps = []` in YAML and the loader doesn't see the\n * runtime-generated steps, so those paths are not affected.\n */\nfunction validateFixtureForMutatingStep(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n if (!MUTATING_TASKS.has(step.task)) return;\n if (step.sample_request !== undefined) return;\n if (step.expect_error === true) return;\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}' (task=${step.task}): ` +\n `mutating tasks require a sample_request fixture — the runner no longer fabricates ` +\n `write payloads. Author sample_request in the step or, for intentionally malformed ` +\n `payloads, set expect_error: true.`\n );\n}\n\n/**\n * `omit_account: true` must be paired with `expect_error: true`.\n *\n * An accountless `create_media_buy` will always be rejected by a spec-compliant\n * seller; a step that sets `omit_account` without `expect_error` will be graded\n * as a failure (not a controlled negative test), producing a misleading\n * compliance result. Fail loud at parse time so the author sees the problem\n * during storyboard load, not at run time.\n */\nfunction validateOmitFlagCoherence(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n if (step.omit_account && step.expect_error !== true) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ` +\n `omit_account: true requires expect_error: true — an accountless ` +\n `create_media_buy will always be rejected by a spec-compliant seller.`\n );\n }\n}\n\n/**\n * Each `context_outputs` entry must declare exactly one source: either\n * `path` (extract from response) or `generate` (mint at run time). An entry\n * with neither is a silent no-op; one with both would silently pick `generate`\n * and ignore `path`. Both are authoring foot-guns that should fail loud.\n */\nfunction validateContextOutputs(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n if (!step.context_outputs?.length) return;\n for (const output of step.context_outputs) {\n const hasPath = output.path !== undefined;\n const hasGenerate = output.generate !== undefined;\n if (!hasPath && !hasGenerate) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': context_outputs entry ` +\n `'${output.key}' must set exactly one of 'path' or 'generate'.`\n );\n }\n if (hasPath && hasGenerate) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': context_outputs entry ` +\n `'${output.key}' sets both 'path' and 'generate' — they are mutually exclusive.`\n );\n }\n // Validate generator name. The runtime resolver also checks but the loader\n // catches typos at storyboard-load time so authors see the failure on\n // build, not on the first run.\n if (hasGenerate && output.generate !== 'uuid_v4' && output.generate !== 'opaque_id') {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': context_outputs entry ` +\n `'${output.key}' has unknown generate value '${output.generate}'. ` +\n `Supported: 'uuid_v4', 'opaque_id'.`\n );\n }\n }\n}\n\n/**\n * Authoring-time validation for `provides_state_for` (the AdCP 3.0.3 spec\n * field — adcp#3734) and the legacy `peer_substitutes_for` synonym. The\n * runner treats the field as same-phase-only and substitution-only-when-\n * stateful; surface those constraints at parse time so storyboard authors\n * see typos and cross-phase references on build, not as a silent no-rescue\n * at run time.\n *\n * Both field names parse to the same canonical normalized form on the step\n * object (the spec name `provides_state_for` is preferred when both are\n * declared). The deprecation alias is documented in `types.ts`.\n *\n * Rules:\n * - Each target must reference a step that exists in the same phase.\n * - A step cannot substitute for itself.\n * - The substitute step itself must be `stateful: true` — non-stateful\n * passes don't establish state per the cascade contract.\n * - The target step must be `stateful: true` — non-stateful targets\n * don't participate in cascade gating, so a substitution declaration\n * would be a no-op.\n * - When both fields are declared on the same step, they must match\n * element-for-element (the deprecation contract is \"synonym for\", not\n * \"additive with\").\n */\nfunction validatePeerSubstitutesFor(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n const newField = step.provides_state_for;\n const legacyField = step.peer_substitutes_for;\n if (newField === undefined && legacyField === undefined) return;\n\n if (newField !== undefined && legacyField !== undefined) {\n // Order-sensitive equality: `[A, B]` vs `[B, A]` would throw despite being\n // semantically equivalent. Authors mid-migration should write the same list\n // in both fields; the deprecation alias is a literal synonym, not a\n // same-set restatement.\n const a = JSON.stringify(Array.isArray(newField) ? newField : [newField]);\n const b = JSON.stringify(Array.isArray(legacyField) ? legacyField : [legacyField]);\n if (a !== b) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': both provides_state_for and ` +\n `peer_substitutes_for declared with different values — pick one (provides_state_for is the ` +\n `spec field; peer_substitutes_for is a deprecated synonym)`\n );\n }\n }\n\n // Normalize onto provides_state_for so the runner can read a single field.\n // peer_substitutes_for stays for back-compat with any consumer code that\n // already reads it.\n if (newField === undefined && legacyField !== undefined) {\n step.provides_state_for = legacyField;\n } else if (newField !== undefined && legacyField === undefined) {\n step.peer_substitutes_for = newField;\n }\n\n const sourceFieldName = newField !== undefined ? 'provides_state_for' : 'peer_substitutes_for';\n const declared = step.provides_state_for!;\n const targets = Array.isArray(declared) ? declared : [declared];\n if (!step.stateful) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} is only legal on stateful steps`\n );\n }\n const phaseStepIds = new Map(phase.steps.map(s => [s.id, s]));\n for (const target of targets) {\n if (typeof target !== 'string' || target.length === 0) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} entries must be non-empty strings`\n );\n }\n if (target === step.id) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} cannot reference itself`\n );\n }\n const targetStep = phaseStepIds.get(target);\n if (!targetStep) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} target '${target}' is not a step in this phase (same-phase only)`\n );\n }\n if (!targetStep.stateful) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}' step '${step.id}': ${sourceFieldName} target '${target}' must be stateful`\n );\n }\n }\n}\n\nfunction validateBranchSet(storyboardId: string, phase: Storyboard['phases'][number]): void {\n if (phase.branch_set === undefined) return;\n const bs = phase.branch_set as unknown;\n if (!bs || typeof bs !== 'object') {\n throw new Error(`[${storyboardId}] phase '${phase.id}': branch_set must be an object with { id, semantics }`);\n }\n const { id, semantics } = bs as Record<string, unknown>;\n if (typeof id !== 'string' || id.length === 0) {\n throw new Error(`[${storyboardId}] phase '${phase.id}': branch_set.id must be a non-empty string`);\n }\n if (typeof semantics !== 'string' || semantics.length === 0) {\n throw new Error(`[${storyboardId}] phase '${phase.id}': branch_set.semantics must be a non-empty string`);\n }\n // Only `any_of` is defined in AdCP today (adcp#2646 lint rule 2 —\n // `at_least_n` and `all_of` are reserved but not defined). Reject unknown\n // values at parse rather than silently skipping grading at runtime, so\n // spec-drift typos fail loud instead of degrading to raw `failed` peers.\n if (!(BRANCH_SET_SEMANTICS as readonly string[]).includes(semantics)) {\n throw new Error(\n `[${storyboardId}] phase '${phase.id}': branch_set.semantics='${semantics}' is not supported (valid: ${BRANCH_SET_SEMANTICS.join(', ')})`\n );\n }\n // Schema constraint: every phase in a branch set MUST be optional. A\n // non-optional branch-set phase would fail the storyboard on any step\n // failure regardless of peer contribution, defeating the any_of gate.\n if (phase.optional !== true) {\n throw new Error(`[${storyboardId}] phase '${phase.id}': phases declaring branch_set must set 'optional: true'`);\n }\n}\n\n/**\n * Resolve the `contributes: true` boolean shorthand introduced alongside the\n * first-class `branch_set:` phase field (adcp-client#693, adcp#2646).\n *\n * Rules:\n * - `contributes: true` is legal only inside a phase that declares `branch_set:`.\n * - A step MUST NOT set both `contributes` and `contributes_to` (ambiguous).\n * - A string `contributes_to` inside a branch_set phase MUST equal `branch_set.id`\n * (otherwise the aggregation target drifts — same invariant the spec lint enforces).\n *\n * After resolution, `step.contributes_to` carries the flag name and `step.contributes`\n * is cleared, so the runner reads a single field regardless of authoring form.\n */\nfunction resolveContributesShorthand(\n storyboardId: string,\n phase: Storyboard['phases'][number],\n step: Storyboard['phases'][number]['steps'][number]\n): void {\n const hasBoolean = step.contributes !== undefined;\n const hasString = step.contributes_to !== undefined;\n\n if (hasBoolean && hasString) {\n throw new Error(`[${storyboardId}] step '${step.id}' declares both 'contributes' and 'contributes_to' — pick one`);\n }\n\n if (hasBoolean) {\n if (step.contributes === true) {\n if (!phase.branch_set) {\n throw new Error(\n `[${storyboardId}] step '${step.id}': 'contributes: true' is only legal inside a phase that declares branch_set`\n );\n }\n step.contributes_to = phase.branch_set.id;\n }\n delete step.contributes;\n return;\n }\n\n if (hasString && phase.branch_set && step.contributes_to !== phase.branch_set.id) {\n throw new Error(\n `[${storyboardId}] step '${step.id}': contributes_to='${step.contributes_to}' must equal enclosing phase's branch_set.id='${phase.branch_set.id}'`\n );\n }\n}\n"],"mappings":"AAQA,SAAS,oBAAoB;AAC7B,SAAS,aAAa;AAEtB,SAAS,sBAAsB;AAC/B,SAAS,6CAA6C;AACtD,SAAS,SAAS,mBAAmB;AACrC,SAAS,2BAA2B;AAO7B,MAAM,uBAAuB,CAAC,QAAQ;AAE7C,MAAM,0BAA0B,OAAO;AACvC,MAAM,0BAA0B,IAAI,OAAO,IAAI,uBAAuB,SAAS,uBAAuB,KAAK;AAC3G,MAAM,0BAA0B;AAGzB,SAAS,gBAAgB,aAAiC;AAC/D,QAAM,SAAS,MAAM,WAAW;AAChC,MAAI,CAAC,QAAQ,MAAM,CAAC,QAAQ,QAAQ;AAClC,UAAM,IAAI,MAAM,+DAA+D;AAAA,EACjF;AACA,MAAI,OAAO,UAAU,eAAe,KAAK,QAAQ,gBAAgB,GAAG;AAClE,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,aAAW,SAAS,OAAO,QAAQ;AAIjC,QAAI,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1C,MAAI,cAAc,WAAW;AAC3B,UAAM,IAAI,MAAM,IAAI,YAAY,WAAW,KAAK,EAAE,oEAA+D;AAAA,EACnH;AAEA,MAAI,YAAY;AACd,QAAI,KAAK,gBAAgB,MAAM;AAC7B,UAAI,CAAC,MAAM,YAAY;AACrB,cAAM,IAAI;AAAA,UACR,IAAI,YAAY,WAAW,KAAK,EAAE;AAAA,QACpC;AAAA,MACF;AACA,WAAK,iBAAiB,MAAM,WAAW;AAAA,IACzC;AACA,WAAO,KAAK;AACZ;AAAA,EACF;AAEA,MAAI,aAAa,MAAM,cAAc,KAAK,mBAAmB,MAAM,WAAW,IAAI;AAChF,UAAM,IAAI;AAAA,MACR,IAAI,YAAY,WAAW,KAAK,EAAE,sBAAsB,KAAK,cAAc,iDAAiD,MAAM,WAAW,EAAE;AAAA,IACjJ;AAAA,EACF;AACF;","names":["prefix"]}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Closed, side-effect-free grammar for storyboard phase `skip_if` guards.
3
+ *
4
+ * Supported forms are deliberately small: runtime references rooted at
5
+ * `context` or `test_kit`, truthiness/negation, `==` / `!=`, boolean and
6
+ * quoted string literals, and logical OR. Anything else is an authoring
7
+ * error rather than an expression that silently falls through to "run".
8
+ */
9
+ export type PhaseConditionScope = {
10
+ context?: Record<string, unknown>;
11
+ test_kit?: unknown;
12
+ };
13
+ type ReferenceNode = {
14
+ kind: 'reference';
15
+ root: 'context' | 'test_kit';
16
+ path: string[];
17
+ };
18
+ type LiteralNode = {
19
+ kind: 'literal';
20
+ value: boolean | string;
21
+ };
22
+ type UnaryNode = {
23
+ kind: 'not';
24
+ operand: PhaseConditionNode;
25
+ };
26
+ type EqualityNode = {
27
+ kind: 'equality';
28
+ operator: '==' | '!=';
29
+ left: ValueNode | UnaryNode;
30
+ right: ValueNode | UnaryNode;
31
+ };
32
+ type OrNode = {
33
+ kind: 'or';
34
+ operands: PhaseConditionNode[];
35
+ };
36
+ type ValueNode = ReferenceNode | LiteralNode;
37
+ export type PhaseConditionNode = ValueNode | UnaryNode | EqualityNode | OrNode;
38
+ export declare function parsePhaseCondition(expression: string): PhaseConditionNode;
39
+ export declare function evaluatePhaseCondition(expression: string, scope: PhaseConditionScope): boolean;
40
+ export declare function phaseConditionUsesContext(expression: string): boolean;
41
+ export {};
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Closed, side-effect-free grammar for storyboard phase `skip_if` guards.
3
+ *
4
+ * Supported forms are deliberately small: runtime references rooted at
5
+ * `context` or `test_kit`, truthiness/negation, `==` / `!=`, boolean and
6
+ * quoted string literals, and logical OR. Anything else is an authoring
7
+ * error rather than an expression that silently falls through to "run".
8
+ */
9
+ export type PhaseConditionScope = {
10
+ context?: Record<string, unknown>;
11
+ test_kit?: unknown;
12
+ };
13
+ type ReferenceNode = {
14
+ kind: 'reference';
15
+ root: 'context' | 'test_kit';
16
+ path: string[];
17
+ };
18
+ type LiteralNode = {
19
+ kind: 'literal';
20
+ value: boolean | string;
21
+ };
22
+ type UnaryNode = {
23
+ kind: 'not';
24
+ operand: PhaseConditionNode;
25
+ };
26
+ type EqualityNode = {
27
+ kind: 'equality';
28
+ operator: '==' | '!=';
29
+ left: ValueNode | UnaryNode;
30
+ right: ValueNode | UnaryNode;
31
+ };
32
+ type OrNode = {
33
+ kind: 'or';
34
+ operands: PhaseConditionNode[];
35
+ };
36
+ type ValueNode = ReferenceNode | LiteralNode;
37
+ export type PhaseConditionNode = ValueNode | UnaryNode | EqualityNode | OrNode;
38
+ export declare function parsePhaseCondition(expression: string): PhaseConditionNode;
39
+ export declare function evaluatePhaseCondition(expression: string, scope: PhaseConditionScope): boolean;
40
+ export declare function phaseConditionUsesContext(expression: string): boolean;
41
+ export {};
42
+ //# sourceMappingURL=phase-condition.d.ts.map