Skip to content

compliance: extend expect_substitution_safe to creative-generative (#2638 follow-up) - #2649

Merged
bokelley merged 3 commits into
mainfrom
bokelley/extend-expect-substitution-safe
Apr 21, 2026
Merged

bokelley merged 3 commits into
mainfrom
bokelley/extend-expect-substitution-safe

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Second consumer of the substitution_observer_runner contract, now that both prerequisites have merged:

  • #2645 — creative-generative got a catalog_augmented_generation phase with build_creative returning preview_html
  • #2647 — the observer contract is live

This PR extends the runtime substitution-safety check from sales-catalog-driven to creative-generative, following the same pattern established by #2647.

What changed

static/compliance/source/specialisms/creative-generative/index.yaml — new catalog_substitution_safety phase appended after catalog_augmented_generation. Three steps:

  1. sync_substitution_probe_catalog — pushes three canonical attacker-shaped values (reserved-character-breakout, nested-expansion-preserved-as-literal, non-ascii-utf8-percent-encoding) as catalog-item sku fields.
  2. build_substitution_probe_creative — generates a creative whose impression tracker URL binds {SKU}, with include_preview: true.
  3. expect_substitution_safe — gated on substitution_observer_runner. Fixture-lookup shape (catalog_item_id + vector_name) with require_every_binding_observed: true.

Why sales-social is NOT included

sales-social uses sync_creatives to register a DPA template but has no AdCP-level preview hook. Social platforms substitute macros at serve time in their own rendering pipeline; they don't expose preview_creative or equivalent. Forcing preview_creative onto required_tools would misalign with real social-platform implementations (Snap, Meta, TikTok DPA all render server-side, not via AdCP).

The substitution_observer_runner contract's observation modes (html_inline, url_fetch) assume substitution happens in an AdCP-visible preview surface. For specialisms without one, a different hook is needed — post-impression log introspection, a dedicated dry_run_substitution endpoint, or an out-of-band conformance-test endpoint. Tracked as a follow-up.

Out of scope / follow-ups

  • sales-social substitution observation — separate issue. Needs new observation mechanism, not just extension of existing phases.
  • sales-retail-media — still a 3.1 placeholder per its specialism file; lands with the retail-media epic.
  • Reference runner implementation of SubstitutionObserver / SubstitutionEncoder — tracked in adcp-client repo.
  • Unicode normalization spec gap (NFC vs NFD) — separate issue against spec(creative): catalog-item macro URL escaping + nested-expansion prohibition (#2558) #2620.

Test plan

  • npm run test:storyboard-scoping passes (3/3)
  • npm run test:error-codes passes (pre-existing YAML warning unrelated)
  • npm run test:unit passes (631 tests)
  • npm run typecheck passes

🤖 Generated with Claude Code

…2638 follow-up)

Second consumer of the substitution_observer_runner contract, now that
both prerequisites merged: #2645 added catalog_augmented_generation
(with build_creative returning preview_html) and #2647 landed the
observer contract.

New catalog_substitution_safety phase on creative-generative/index.yaml
mirrors the sales-catalog-driven pattern:

1. sync_substitution_probe_catalog — pushes three canonical attacker-
   shaped values (reserved-character-breakout, nested-expansion-
   preserved-as-literal, non-ascii-utf8-percent-encoding) as catalog-
   item sku fields.
2. build_substitution_probe_creative — generates a creative with
   {SKU} in the impression tracker URL + include_preview: true.
3. expect_substitution_safe — gated on substitution_observer_runner.
   Uses fixture-lookup shape (catalog_item_id + vector_name) with
   require_every_binding_observed: true.

sales-social deliberately deferred: social platforms substitute at
serve time in their own rendering pipeline — no natural AdCP-level
preview hook. Forcing preview_creative on required_tools would
misalign with real implementations. Separate issue to follow for
specialisms without preview surfaces (post-impression observation,
dry-run substitution endpoint, or similar).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Three reviewers (protocol + security + DX) landed consistent findings:

- Extend vector coverage (convergent across protocol + security + DX):
  the initial phase tested only 3 of 7 canonical fixture vectors.
  Added crlf_injection and bidi_override items to the probe catalog
  + matching catalog_bindings. Generative specialism specifically
  flagged bidi as higher-risk (LLM-generated copy with embedded user
  text round-trips bidi into attribute contexts). 5 of 7 vectors now
  bound; mixed-path-and-query (same macro in two URL positions) and
  url-scheme-injection-neutralized (href-whole-value binding) are
  template-shape follow-ups.

- Fix stale applies_to.specialisms in observer contract (protocol):
  sales_social was listed as a current consumer but #2649 explicitly
  deferred it (no preview hook on social platforms). Moved to a
  "Deferred pending observation-hook design (#2651)" comment;
  removed from applies_to.specialisms array.

- Add diagnostic validation on build step (security): the message
  field is a natural-language brief; an LLM that ignores the {SKU}
  directive fails with a generic substitution_binding_missing. Made
  the brief more explicit ("use the literal `{SKU}` macro
  (unsubstituted) in at least one impression tracker URL...") to
  surface the directive more clearly. Narrative now explicitly
  diagnoses the failure mode.

- Narrative tweaks (security + DX):
  * List all five bound vectors + name the two template-shape
    follow-ups (mixed-path, url-scheme-injection).
  * Add explicit scope note — phase validates PREVIEW surface only;
    serve-time attestation deferred per #2651 and the observer
    contract's out-of-scope v1.

DX copy-paste abstraction (future author friction) and vector_name
authoring-time validation are flagged as 3.1 follow-ups, not in-PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Two cleanups from round-2 expert reviews:

- Protocol (both reviewers): sales-catalog-driven narrative said
  "six canonical" vectors but only three items existed. Narrative
  now matches the three actually exercised + explicit cross-reference
  to creative-generative for CRLF + bidi coverage + note that mixed-
  path-and-query and url-scheme-injection are template-shape
  follow-ups (unit-test layer only).

- DX: "unsubstituted" wording in the creative-generative build brief
  read contradictorily on first pass. Rephrased to "Include the
  {SKU} macro as a literal token in the impression tracker URL —
  the platform resolves it per-impression against catalog items."

No functional change. Both reviewers said mergeable with these nits.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bokelley
bokelley merged commit 39cc871 into main Apr 21, 2026
14 checks passed
bokelley added a commit that referenced this pull request May 15, 2026
…ety phase (#4566)

sales-social previously deferred runtime substitution-safety checks
pending an observation-hook design (#2651, closed). The premise that
social platforms have no AdCP-level preview hook didn't hold — Meta
creative_preview, TikTok/Snap creative-preview APIs, and Amazon Ads /
Walmart Connect previews all exercise catalog-item macro substitution
as part of rendering.

Wire sales-social to the existing substitution_observer_runner test-kit
contract using the same preview surface creative-generative already
uses post-#2649. No new capability, no new schema.

Changes:
- static/compliance/source/specialisms/sales-social/index.yaml
  - Add preview_creative to required_tools
  - New catalog_substitution_safety phase: push probe catalog with
    attacker-shaped values → push DPA creative bound to the probe →
    call preview_creative → observe substituted URLs via the runner
    contract
  - Update catalog_driven_dynamic_ads narrative — drop the deferral
- static/compliance/source/test-kits/substitution-observer-runner.yaml
  - Add sales_social to applies_to.specialisms
  - Remove the deferred-pending-#2651 comment block

Coverage limitation (same as creative-generative): preview-time
substitution may diverge from impression-time on platforms with
different code paths. Serve-time attestation remains a known gap and
is not gated for this phase.

Closes #4546.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant