@adcp/sdk 13.0.0-rc.10 → 13.0.0-rc.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 (116) hide show
  1. package/dist/lib/core/AgentClient.d.mts +12 -3
  2. package/dist/lib/core/AgentClient.d.ts +12 -3
  3. package/dist/lib/core/AgentClient.d.ts.map +1 -1
  4. package/dist/lib/core/AgentClient.js +12 -3
  5. package/dist/lib/core/AgentClient.js.map +1 -1
  6. package/dist/lib/core/AgentClient.mjs +12 -3
  7. package/dist/lib/core/AgentClient.mjs.map +1 -1
  8. package/dist/lib/core/SingleAgentClient.d.mts +13 -3
  9. package/dist/lib/core/SingleAgentClient.d.ts +13 -3
  10. package/dist/lib/core/SingleAgentClient.d.ts.map +1 -1
  11. package/dist/lib/core/SingleAgentClient.js +52 -31
  12. package/dist/lib/core/SingleAgentClient.js.map +1 -1
  13. package/dist/lib/core/SingleAgentClient.mjs +52 -31
  14. package/dist/lib/core/SingleAgentClient.mjs.map +1 -1
  15. package/dist/lib/index.d.mts +1 -1
  16. package/dist/lib/index.d.ts +1 -1
  17. package/dist/lib/index.d.ts.map +1 -1
  18. package/dist/lib/index.js +8 -0
  19. package/dist/lib/index.js.map +1 -1
  20. package/dist/lib/index.mjs +8 -0
  21. package/dist/lib/index.mjs.map +1 -1
  22. package/dist/lib/registry/types.generated.d.mts +48 -1
  23. package/dist/lib/registry/types.generated.d.ts +48 -1
  24. package/dist/lib/registry/types.generated.d.ts.map +1 -1
  25. package/dist/lib/registry/types.generated.js.map +1 -1
  26. package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
  27. package/dist/lib/server/decisioning/runtime/from-platform.d.mts +1 -1
  28. package/dist/lib/server/decisioning/runtime/from-platform.d.ts +1 -1
  29. package/dist/lib/server/decisioning/runtime/from-platform.d.ts.map +1 -1
  30. package/dist/lib/server/decisioning/runtime/from-platform.js +389 -65
  31. package/dist/lib/server/decisioning/runtime/from-platform.js.map +1 -1
  32. package/dist/lib/server/decisioning/runtime/from-platform.mjs +389 -65
  33. package/dist/lib/server/decisioning/runtime/from-platform.mjs.map +1 -1
  34. package/dist/lib/testing/compliance/comply.d.ts.map +1 -1
  35. package/dist/lib/testing/compliance/comply.js +8 -2
  36. package/dist/lib/testing/compliance/comply.js.map +1 -1
  37. package/dist/lib/testing/compliance/comply.mjs +8 -2
  38. package/dist/lib/testing/compliance/comply.mjs.map +1 -1
  39. package/dist/lib/testing/compliance/spec-conformance.d.ts.map +1 -1
  40. package/dist/lib/testing/compliance/spec-conformance.js +2 -0
  41. package/dist/lib/testing/compliance/spec-conformance.js.map +1 -1
  42. package/dist/lib/testing/compliance/spec-conformance.mjs +2 -0
  43. package/dist/lib/testing/compliance/spec-conformance.mjs.map +1 -1
  44. package/dist/lib/testing/compliance/summary.d.mts +2 -0
  45. package/dist/lib/testing/compliance/summary.d.ts +2 -0
  46. package/dist/lib/testing/compliance/summary.d.ts.map +1 -1
  47. package/dist/lib/testing/compliance/summary.js +3 -2
  48. package/dist/lib/testing/compliance/summary.js.map +1 -1
  49. package/dist/lib/testing/compliance/summary.mjs +3 -2
  50. package/dist/lib/testing/compliance/summary.mjs.map +1 -1
  51. package/dist/lib/testing/compliance/types.d.mts +4 -0
  52. package/dist/lib/testing/compliance/types.d.ts +4 -0
  53. package/dist/lib/testing/compliance/types.d.ts.map +1 -1
  54. package/dist/lib/testing/compliance/types.js.map +1 -1
  55. package/dist/lib/testing/storyboard/junit.js +49 -32
  56. package/dist/lib/testing/storyboard/junit.js.map +1 -1
  57. package/dist/lib/testing/storyboard/junit.mjs +49 -32
  58. package/dist/lib/testing/storyboard/junit.mjs.map +1 -1
  59. package/dist/lib/testing/storyboard/loader.d.ts.map +1 -1
  60. package/dist/lib/testing/storyboard/loader.js +26 -0
  61. package/dist/lib/testing/storyboard/loader.js.map +1 -1
  62. package/dist/lib/testing/storyboard/loader.mjs +26 -0
  63. package/dist/lib/testing/storyboard/loader.mjs.map +1 -1
  64. package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
  65. package/dist/lib/testing/storyboard/runner.js +66 -15
  66. package/dist/lib/testing/storyboard/runner.js.map +1 -1
  67. package/dist/lib/testing/storyboard/runner.mjs +70 -16
  68. package/dist/lib/testing/storyboard/runner.mjs.map +1 -1
  69. package/dist/lib/testing/storyboard/types.d.mts +26 -1
  70. package/dist/lib/testing/storyboard/types.d.ts +26 -1
  71. package/dist/lib/testing/storyboard/types.d.ts.map +1 -1
  72. package/dist/lib/testing/storyboard/types.js.map +1 -1
  73. package/dist/lib/testing/storyboard/types.mjs.map +1 -1
  74. package/dist/lib/testing/storyboard/validations.d.mts +11 -0
  75. package/dist/lib/testing/storyboard/validations.d.ts +11 -0
  76. package/dist/lib/testing/storyboard/validations.d.ts.map +1 -1
  77. package/dist/lib/testing/storyboard/validations.js +30 -13
  78. package/dist/lib/testing/storyboard/validations.js.map +1 -1
  79. package/dist/lib/testing/storyboard/validations.mjs +27 -13
  80. package/dist/lib/testing/storyboard/validations.mjs.map +1 -1
  81. package/dist/lib/v2/projection/augment-response.d.mts +45 -0
  82. package/dist/lib/v2/projection/augment-response.d.ts +45 -0
  83. package/dist/lib/v2/projection/augment-response.d.ts.map +1 -1
  84. package/dist/lib/v2/projection/augment-response.js +54 -0
  85. package/dist/lib/v2/projection/augment-response.js.map +1 -1
  86. package/dist/lib/v2/projection/augment-response.mjs +52 -0
  87. package/dist/lib/v2/projection/augment-response.mjs.map +1 -1
  88. package/dist/lib/v2/projection/index.d.mts +7 -1
  89. package/dist/lib/v2/projection/index.d.ts +7 -1
  90. package/dist/lib/v2/projection/index.d.ts.map +1 -1
  91. package/dist/lib/v2/projection/index.js +9 -0
  92. package/dist/lib/v2/projection/index.js.map +1 -1
  93. package/dist/lib/v2/projection/index.mjs +10 -0
  94. package/dist/lib/v2/projection/index.mjs.map +1 -1
  95. package/dist/lib/v2/projection/legacy-routes.d.mts +24 -0
  96. package/dist/lib/v2/projection/legacy-routes.d.ts +25 -0
  97. package/dist/lib/v2/projection/legacy-routes.d.ts.map +1 -0
  98. package/dist/lib/v2/projection/legacy-routes.js +163 -0
  99. package/dist/lib/v2/projection/legacy-routes.js.map +1 -0
  100. package/dist/lib/v2/projection/legacy-routes.mjs +138 -0
  101. package/dist/lib/v2/projection/legacy-routes.mjs.map +1 -0
  102. package/dist/lib/v2/projection/v1-to-v2.d.mts +3 -0
  103. package/dist/lib/v2/projection/v1-to-v2.d.ts +3 -0
  104. package/dist/lib/v2/projection/v1-to-v2.d.ts.map +1 -1
  105. package/dist/lib/v2/projection/v1-to-v2.js +2 -1
  106. package/dist/lib/v2/projection/v1-to-v2.js.map +1 -1
  107. package/dist/lib/v2/projection/v1-to-v2.mjs +2 -1
  108. package/dist/lib/v2/projection/v1-to-v2.mjs.map +1 -1
  109. package/dist/lib/version.d.mts +3 -3
  110. package/dist/lib/version.d.ts +3 -3
  111. package/dist/lib/version.js +3 -3
  112. package/dist/lib/version.js.map +1 -1
  113. package/dist/lib/version.mjs +3 -3
  114. package/dist/lib/version.mjs.map +1 -1
  115. package/docs/migration-12-to-13.md +56 -2
  116. package/package.json +3 -1
@@ -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';\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})*$`);\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 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 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 validatePeerSubstitutesFor(storyboard.id, phase, step);\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;AAO/C,MAAM,uBAAuB,CAAC,QAAQ;AAE7C,MAAM,0BAA0B,OAAO;AACvC,MAAM,0BAA0B,IAAI,OAAO,IAAI,uBAAuB,SAAS,uBAAuB,KAAK;AAGpG,SAAS,gBAAgB,aAAiC;AAC/D,QAAM,aAAS,mBAAM,WAAW;AAChC,MAAI,CAAC,QAAQ,MAAM,CAAC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AAY,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":[]}
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})*$`);\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 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 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 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;AAGpG,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,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;A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A,MACR,IAAI,YAAY,WAAW,KAAK,EAAE,sBAAsB,KAAK,cAAc,iDAAiD,MAAM,WAAW,EAAE;AAAA,IACjJ;AAAA,EACF;AACF;","names":["prefix","validSemver"]}
@@ -2,6 +2,7 @@ import { readFileSync } from "fs";
2
2
  import { parse } from "yaml";
3
3
  import { MUTATING_TASKS } from "../../utils/idempotency.mjs";
4
4
  import { validateFixtureResolutionDeclarations } from "./fixture-resolution.mjs";
5
+ import { valid as validSemver } from "semver";
5
6
  const BRANCH_SET_SEMANTICS = ["any_of"];
6
7
  const IDENTIFIER_PATH_SEGMENT = String.raw`[A-Za-z_][A-Za-z0-9_-]*(?:\[\*\])*`;
7
8
  const IDENTIFIER_PATH_PATTERN = new RegExp(`^${IDENTIFIER_PATH_SEGMENT}(?:\\.${IDENTIFIER_PATH_SEGMENT})*$`);
@@ -43,10 +44,35 @@ function validateStoryboardShape(storyboard) {
43
44
  validateContextOutputs(storyboard.id, phase, step);
44
45
  validateUpstreamAttestationMode(storyboard.id, phase, step);
45
46
  validateUpstreamIdentifierPaths(storyboard.id, phase, step);
47
+ validateAdvisoryDeclarations(storyboard.id, phase, step);
46
48
  validatePeerSubstitutesFor(storyboard.id, phase, step);
47
49
  }
48
50
  }
49
51
  }
52
+ function validateAdvisoryDeclarations(storyboardId, phase, step) {
53
+ for (let index = 0; index < (step.validations ?? []).length; index++) {
54
+ const validation = step.validations[index];
55
+ if (validation?.severity !== void 0 && validation.severity !== "required" && validation.severity !== "advisory") {
56
+ const prefix2 = `[${storyboardId}] ${phase.id ?? "?"}.${step.id ?? "?"}.validations[${index}]`;
57
+ throw new Error(`${prefix2}.severity: must be either "required" or "advisory"`);
58
+ }
59
+ if (validation?.severity !== "advisory") continue;
60
+ const prefix = `[${storyboardId}] ${phase.id ?? "?"}.${step.id ?? "?"}.validations[${index}]`;
61
+ const hasExpiry = validation.expires_after_version !== void 0;
62
+ const hasPermanent = validation.permanent_advisory !== void 0;
63
+ if (hasExpiry === hasPermanent) {
64
+ throw new Error(
65
+ `${prefix}: severity "advisory" must declare exactly one of expires_after_version or permanent_advisory`
66
+ );
67
+ }
68
+ if (hasExpiry && (typeof validation.expires_after_version !== "string" || !validSemver(validation.expires_after_version))) {
69
+ throw new Error(`${prefix}.expires_after_version: must be a valid semver string`);
70
+ }
71
+ if (hasPermanent && (typeof validation.permanent_advisory !== "object" || validation.permanent_advisory === null || typeof validation.permanent_advisory.reason !== "string" || validation.permanent_advisory.reason.trim().length === 0)) {
72
+ throw new Error(`${prefix}.permanent_advisory.reason: must be a non-empty string`);
73
+ }
74
+ }
75
+ }
50
76
  function validateUpstreamAttestationMode(storyboardId, phase, step) {
51
77
  const validations = step.validations ?? [];
52
78
  for (let validationIndex = 0; validationIndex < validations.length; validationIndex++) {
@@ -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';\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})*$`);\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 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 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 validatePeerSubstitutesFor(storyboard.id, phase, step);\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;AAO/C,MAAM,uBAAuB,CAAC,QAAQ;AAE7C,MAAM,0BAA0B,OAAO;AACvC,MAAM,0BAA0B,IAAI,OAAO,IAAI,uBAAuB,SAAS,uBAAuB,KAAK;AAGpG,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,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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,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":[]}
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})*$`);\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 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 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 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;AAGpG,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,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,gBAAgB,aAAa,UAAU,OAAO,CAAC;AACxD;AAWO,SAAS,wBAAwB,YAA8B;AACpE,mBAAiB,UAAU;AAC3B,wCAAsC,UAAU;AAChD,6BAA2B,UAAU;AACrC,yBAAuB,UAAU;AACjC,aAAW,SAAS,WAAW,QAAQ;AACrC,sBAAkB,WAAW,IAAI,KAAK;AACt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AAY,UAAU,WAAW,GAAG;AAC3D,UAAM,IAAI,MAAM,IAAI,YAAY,YAAY,MAAM,EAAE,oDAAoD;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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../../src/lib/testing/storyboard/runner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA6FH,OAAO,KAAK,EAiBV,2BAA2B,EAG3B,UAAU,EACV,cAAc,EAEd,iBAAiB,EACjB,oBA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AAM,EACjB,SAAS,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,GACrC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAyDzB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAyBpH;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,cAAc,GACnB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAKzB;AAkfD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,iBAAsB,GAC9B,qBAAqB,GAAG,SAAS,CAgBnC"}
@@ -701,6 +701,7 @@ function buildCapabilityUnsupportedResult(agentUrls, storyboard, detail) {
701
701
  passed_count: 0,
702
702
  failed_count: 0,
703
703
  skipped_count: 1,
704
+ runner_capability_version: import_validations.RUNNER_CAPABILITY_VERSION,
704
705
  tested_at: (/* @__PURE__ */ new Date()).toISOString(),
705
706
  strict_validation_summary: {
706
707
  observable: false,
@@ -783,6 +784,7 @@ function buildRequirementUnmetResult(agentUrls, storyboard, requirement, detail)
783
784
  passed_count: 0,
784
785
  failed_count: 0,
785
786
  skipped_count: 1,
787
+ runner_capability_version: import_validations.RUNNER_CAPABILITY_VERSION,
786
788
  tested_at: (/* @__PURE__ */ new Date()).toISOString(),
787
789
  strict_validation_summary: {
788
790
  observable: false,
@@ -830,6 +832,7 @@ function buildRequiredAnyOfToolsMissingResult(agentUrls, storyboard, detail) {
830
832
  passed_count: 0,
831
833
  failed_count: 0,
832
834
  skipped_count: 1,
835
+ runner_capability_version: import_validations.RUNNER_CAPABILITY_VERSION,
833
836
  tested_at: (/* @__PURE__ */ new Date()).toISOString(),
834
837
  strict_validation_summary: {
835
838
  observable: false,
@@ -1038,6 +1041,7 @@ function buildDiscoveryFailedResult(agentUrls, storyboard, discoveryStep) {
1038
1041
  passed_count: 0,
1039
1042
  failed_count: 1,
1040
1043
  skipped_count: 0,
1044
+ runner_capability_version: import_validations.RUNNER_CAPABILITY_VERSION,
1041
1045
  tested_at: (/* @__PURE__ */ new Date()).toISOString(),
1042
1046
  strict_validation_summary: {
1043
1047
  observable: false,
@@ -1086,6 +1090,7 @@ function buildRequiredToolsMissingResult(agentUrls, storyboard, detail) {
1086
1090
  passed_count: 0,
1087
1091
  failed_count: 0,
1088
1092
  skipped_count: 1,
1093
+ runner_capability_version: import_validations.RUNNER_CAPABILITY_VERSION,
1089
1094
  tested_at: (/* @__PURE__ */ new Date()).toISOString(),
1090
1095
  strict_validation_summary: {
1091
1096
  observable: false,
@@ -1807,7 +1812,9 @@ async function executeStoryboardPass(agentUrls, storyboard, options, dispatchOff
1807
1812
  }
1808
1813
  stepResults.push(result2);
1809
1814
  priorStepResults.set(step.id, result2);
1810
- const schemaInvalidResponse = result2.validations.some((v) => v.check === "response_schema" && !v.passed);
1815
+ const schemaInvalidResponse = result2.validations.some(
1816
+ (v) => v.check === "response_schema" && (0, import_validations.validationFailsStep)(v)
1817
+ );
1811
1818
  for (const spec of assertions) {
1812
1819
  if (!spec.onStep) continue;
1813
1820
  if ((0, import_assertions.stepDisablesAssertion)(step.invariants, spec.id)) continue;
@@ -2037,6 +2044,7 @@ async function executeStoryboardPass(agentUrls, storyboard, options, dispatchOff
2037
2044
  const schemasUsed = collectSchemasUsed(phaseResults);
2038
2045
  const strictSummary = summarizeStrictValidation(phaseResults);
2039
2046
  const validationsNotApplicable = countValidationsNotApplicable(phaseResults);
2047
+ const validationsAdvisoryFailed = countValidationsAdvisoryFailed(phaseResults);
2040
2048
  const notices = mergeRunnerNotices([
2041
2049
  ...collectCapabilityNotices(storyboard, profile ?? options._profile),
2042
2050
  ...collectStepNotices(phaseResults)
@@ -2062,7 +2070,9 @@ async function executeStoryboardPass(agentUrls, storyboard, options, dispatchOff
2062
2070
  passed_count: passedCount,
2063
2071
  failed_count: failedCount,
2064
2072
  skipped_count: skippedCount,
2073
+ ...validationsAdvisoryFailed > 0 ? { validations_advisory_failed: validationsAdvisoryFailed } : {},
2065
2074
  ...validationsNotApplicable > 0 ? { validations_not_applicable: validationsNotApplicable } : {},
2075
+ runner_capability_version: import_validations.RUNNER_CAPABILITY_VERSION,
2066
2076
  tested_at: (/* @__PURE__ */ new Date()).toISOString(),
2067
2077
  ...schemasUsed.length > 0 ? { schemas_used: schemasUsed } : {},
2068
2078
  ...assertionResults.length > 0 ? { assertions: assertionResults } : {},
@@ -2144,6 +2154,7 @@ async function runMultiPass(agentUrls, storyboard, options) {
2144
2154
  passed_count: result.passed_count,
2145
2155
  failed_count: result.failed_count,
2146
2156
  skipped_count: result.skipped_count,
2157
+ ...result.validations_advisory_failed ? { validations_advisory_failed: result.validations_advisory_failed } : {},
2147
2158
  ...result.validations_not_applicable ? { validations_not_applicable: result.validations_not_applicable } : {},
2148
2159
  duration_ms: result.total_duration_ms
2149
2160
  });
@@ -2153,6 +2164,7 @@ async function runMultiPass(agentUrls, storyboard, options) {
2153
2164
  const passed = passes.reduce((sum, p) => sum + p.passed_count, 0);
2154
2165
  const failed = passes.reduce((sum, p) => sum + p.failed_count, 0);
2155
2166
  const skipped = passes.reduce((sum, p) => sum + p.skipped_count, 0);
2167
+ const advisoryFailed = passes.reduce((sum, p) => sum + (p.validations_advisory_failed ?? 0), 0);
2156
2168
  const notApplicable = passes.reduce((sum, p) => sum + (p.validations_not_applicable ?? 0), 0);
2157
2169
  const schemasUsed = passResults.flatMap((r) => r.schemas_used ?? []);
2158
2170
  const schemasDedup = [...new Map(schemasUsed.map((s) => [s.schema_id, s])).values()];
@@ -2172,7 +2184,9 @@ async function runMultiPass(agentUrls, storyboard, options) {
2172
2184
  passed_count: passed,
2173
2185
  failed_count: failed,
2174
2186
  skipped_count: skipped,
2187
+ ...advisoryFailed > 0 ? { validations_advisory_failed: advisoryFailed } : {},
2175
2188
  ...notApplicable > 0 ? { validations_not_applicable: notApplicable } : {},
2189
+ runner_capability_version: import_validations.RUNNER_CAPABILITY_VERSION,
2176
2190
  tested_at: (/* @__PURE__ */ new Date()).toISOString(),
2177
2191
  ...schemasDedup.length > 0 ? { schemas_used: schemasDedup } : {},
2178
2192
  ...assertionsAgg.length > 0 ? { assertions: assertionsAgg } : {},
@@ -2192,6 +2206,17 @@ function countValidationsNotApplicable(phases) {
2192
2206
  }
2193
2207
  return n;
2194
2208
  }
2209
+ function countValidationsAdvisoryFailed(phases) {
2210
+ let n = 0;
2211
+ for (const phase of phases) {
2212
+ for (const step of phase.steps) {
2213
+ for (const validation of step.validations) {
2214
+ if (!validation.passed && validation.severity === "advisory") n++;
2215
+ }
2216
+ }
2217
+ }
2218
+ return n;
2219
+ }
2195
2220
  function collectSchemasUsed(phases) {
2196
2221
  const seen = /* @__PURE__ */ new Set();
2197
2222
  const out = [];
@@ -2896,8 +2921,16 @@ async function executeStep(client, step, storyboardId, phaseId, context, allStep
2896
2921
  } else {
2897
2922
  passed = stepResult.passed && (taskResult?.success ?? false);
2898
2923
  }
2924
+ const schemaValidationError = caughtError instanceof import_response_unwrapper.ResponseSchemaValidationError ? caughtError : void 0;
2925
+ const validationTaskResult = taskResult ?? (schemaValidationError ? {
2926
+ // ResponseSchemaValidationError is thrown while validating a
2927
+ // successful response arm. Preserve that terminal state so
2928
+ // status_code/error_code checks retain their authored semantics.
2929
+ success: true,
2930
+ data: schemaValidationError.data
2931
+ } : void 0);
2899
2932
  let validations = [];
2900
- if (step.validations?.length && (taskResult || httpResult)) {
2933
+ if (step.validations?.length && (validationTaskResult || httpResult)) {
2901
2934
  const resolvedValidations = step.validations.map((v) => {
2902
2935
  const resolved = { ...v };
2903
2936
  if (resolved.value !== void 0) {
@@ -2924,7 +2957,7 @@ async function executeStep(client, step, storyboardId, phaseId, context, allStep
2924
2957
  taskName: effectiveStep.task,
2925
2958
  ...options.adcpVersion && { adcpVersion: options.adcpVersion },
2926
2959
  ...options._serverAdcpVersion && { responseAdcpVersion: options._serverAdcpVersion },
2927
- ...taskResult && { taskResult },
2960
+ ...validationTaskResult && { taskResult: validationTaskResult },
2928
2961
  ...httpResult && { httpResult },
2929
2962
  agentUrl: runState.agentUrl,
2930
2963
  contributions: runState.contributions,
@@ -2981,20 +3014,38 @@ async function executeStep(client, step, storyboardId, phaseId, context, allStep
2981
3014
  }
2982
3015
  }
2983
3016
  }
2984
- if (caughtError instanceof import_response_unwrapper.ResponseSchemaValidationError) {
2985
- const issues = caughtError.issues.slice(0, 5).map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
2986
- const firstIssue = caughtError.issues[0];
3017
+ let schemaRejectionIsAdvisory = false;
3018
+ if (schemaValidationError) {
3019
+ const issues = schemaValidationError.issues.slice(0, 5).map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
3020
+ const firstIssue = schemaValidationError.issues[0];
2987
3021
  const jsonPointer = firstIssue ? "/" + firstIssue.path.map((s) => String(s)).join("/") : null;
2988
- const synthSchemaResult = {
3022
+ const baseSchemaResult = {
2989
3023
  check: "response_schema",
2990
3024
  passed: false,
2991
- description: `Response schema validation for ${caughtError.toolName}`,
3025
+ description: `Response schema validation for ${schemaValidationError.toolName}`,
2992
3026
  error: issues,
2993
3027
  json_pointer: jsonPointer,
2994
- expected: `response schema for ${caughtError.toolName}`,
2995
- actual: caughtError.issues
3028
+ expected: `response schema for ${schemaValidationError.toolName}`,
3029
+ actual: schemaValidationError.issues
2996
3030
  };
2997
- validations = [synthSchemaResult, ...validations];
3031
+ const authoredSchemaValidations = (step.validations ?? []).filter((v) => v.check === "response_schema");
3032
+ const schemaValidationContext = {
3033
+ taskName: effectiveStep.task,
3034
+ ...options.adcpVersion && { adcpVersion: options.adcpVersion },
3035
+ ...options._serverAdcpVersion && { responseAdcpVersion: options._serverAdcpVersion },
3036
+ ...validationTaskResult && { taskResult: validationTaskResult },
3037
+ agentUrl: runState.agentUrl,
3038
+ contributions: runState.contributions,
3039
+ request: requestRecord,
3040
+ ...responseRecord && { response: responseRecord }
3041
+ };
3042
+ const decoratedCandidates = authoredSchemaValidations.map(
3043
+ (validation) => (0, import_validations.decorateValidationResult)(baseSchemaResult, schemaValidationContext, validation)
3044
+ );
3045
+ const schemaResults = decoratedCandidates.length ? decoratedCandidates : [{ ...baseSchemaResult, severity: "required" }];
3046
+ schemaRejectionIsAdvisory = schemaResults.every((result) => !(0, import_validations.validationFailsStep)(result));
3047
+ if (schemaRejectionIsAdvisory && !step.expect_error) passed = true;
3048
+ validations = [...schemaResults, ...validations.filter((result) => result.check !== "response_schema")];
2998
3049
  }
2999
3050
  if (a2aEnvelope && runState.priorA2aEnvelopes) {
3000
3051
  runState.priorA2aEnvelopes.set(step.id, a2aEnvelope);
@@ -3079,7 +3130,7 @@ async function executeStep(client, step, storyboardId, phaseId, context, allStep
3079
3130
  }
3080
3131
  }
3081
3132
  }
3082
- const allValidationsPassedFinal = validations.every((v) => v.passed);
3133
+ const allValidationsPassedFinal = validations.every((v) => !(0, import_validations.validationFailsStep)(v));
3083
3134
  const stepFailed = !(passed && allValidationsPassedFinal);
3084
3135
  const contextRejectionHints = stepFailed && runState.contextProvenance ? (0, import_rejection_hints.detectContextRejectionHints)(taskResult, request, context, runState.contextProvenance, effectiveStep.task) : [];
3085
3136
  const driftPayload = (() => {
@@ -3114,7 +3165,7 @@ async function executeStep(client, step, storyboardId, phaseId, context, allStep
3114
3165
  context_provenance: Object.fromEntries(runState.contextProvenance)
3115
3166
  },
3116
3167
  ...responseDerivedContextResult(runState),
3117
- error: step.expect_error ? void 0 : truncateError(stepResult.error || taskResult?.error),
3168
+ error: step.expect_error || schemaRejectionIsAdvisory ? void 0 : truncateError(stepResult.error || taskResult?.error),
3118
3169
  ...!step.expect_error && taskResult?.adcp_error && { adcp_error: taskResult.adcp_error },
3119
3170
  next,
3120
3171
  request: requestRecord,
@@ -3420,7 +3471,7 @@ async function executeProbeStep(client, step, phaseId, context, allSteps, option
3420
3471
  ...oauthMetadataGraph && { oauthMetadataGraph }
3421
3472
  };
3422
3473
  const validations = step.validations?.length ? (0, import_validations.runValidations)(step.validations, vctx) : [];
3423
- const allValidationsPassed = validations.every((v) => v.passed);
3474
+ const allValidationsPassed = validations.every((v) => !(0, import_validations.validationFailsStep)(v));
3424
3475
  const fetchOk = httpResult ? !httpResult.error : true;
3425
3476
  const passed = fetchOk && allValidationsPassed;
3426
3477
  const extraction = httpResult ? httpResult.error ? { path: "error" } : { path: "structured_content", note: "http-probe body parsed as JSON" } : { path: "none" };
@@ -3628,7 +3679,7 @@ async function executeReplayWebhookVectorStep(step, phaseId, context, allSteps,
3628
3679
  body: (0, import_redact_secrets.redactSecrets)(httpResult.body)
3629
3680
  };
3630
3681
  const validations = buildWebhookReplayValidations(step, vector, allSteps, options, requestRecord, responseRecord);
3631
- const allValidationsPassed = validations.every((v) => v.passed);
3682
+ const allValidationsPassed = validations.every((v) => !(0, import_validations.validationFailsStep)(v));
3632
3683
  const fetchOk = !httpResult.error;
3633
3684
  const passed = fetchOk && allValidationsPassed;
3634
3685
  return {