Skip to content

fix(codegen): find generated classes by name, and derive emitted envelope bases from the bundle - #1705

Open
bokelley wants to merge 1 commit into
nextfrom
claude/issue-1680-envelope-matchers
Open

bokelley wants to merge 1 commit into
nextfrom
claude/issue-1680-envelope-matchers

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Closes #1680. scripts/post_generate_fixes.py matched 29 exact class-signature strings (class X(AdcpVersionEnvelope, ProtocolEnvelope):). adcp#8547 changes the generated response classes to class X(ProtocolEnvelope):, which made one pass raise ListCreativesResponse marker missing and would have let the status-alias, verify-brand-claim and compatibility-enum passes skip silently.

  • Every pass that needs a generated class finds it by name (find_class_header / require_class_header) and keeps whatever bases the generator wrote; a missing class is a RuntimeError naming the pass.
  • The classes the script emits (response arms, constructible compatibility bases, the verify_brand_claim(s) modules) take their envelope bases from response_envelope_bases(), which reads whether the generated ProtocolEnvelope already composes AdcpVersionEnvelope, and drop the version-envelope import when nothing uses it. The identity-match constant anchors on either envelope import.
  • tests/test_post_generate_envelope_matchers.py (11 tests) exercises the passes under both compositions and guards against a full-signature marker reappearing.

Measured

  • Today's 3.3.0-beta.1 tree: make validate-generated passes (byte-for-byte), tests/test_code_generation.py and the no-explicit-null rewrite tests pass.
  • adcp#8547's schema tree (overlaid onto a scratch cache with bundle-style refs): the post-generation passes run to completion and emit class X(AdcpResponse, ProtocolEnvelope): for 117 response arms plus (AdcpResponse, ResponseArmDispatchMixin, ProtocolEnvelope) for the five constructible bases, where the run crashed before. The status-alias and ListCreatives XOR passes apply. That run still stops later, in export consolidation, on a circular import the new schema set exposes (core/creative_assets.py evaluates asset_union.AssetVariant at class definition while asset_union is mid-import); that belongs to the Generated response types can't represent the protocol envelope #1678 regeneration and is written up there.

🤖 Generated with Claude Code

…lope bases from the bundle

scripts/post_generate_fixes.py matched 29 exact class-signature strings such
as "class ListCreativesResponse(AdcpVersionEnvelope, ProtocolEnvelope):".
adcp#8547 makes core/protocol-envelope.json compose
core/version-envelope.json and every task response compose only the protocol
envelope, so the generated classes become "class X(ProtocolEnvelope):"; one
pass then raised "ListCreativesResponse marker missing" and the status-alias,
verify-brand-claim and compatibility-enum passes would have skipped silently
(#1680).

Every pass that needs a generated class now finds it by name
(find_class_header / require_class_header) and keeps whatever bases the
generator wrote; a class that is gone is a RuntimeError naming the pass. The
classes this script emits itself (response arms, the constructible
compatibility bases, the verify_brand_claim modules) take their envelope bases
from response_envelope_bases(), which reads whether the generated
ProtocolEnvelope already composes AdcpVersionEnvelope, and drop the
version-envelope import when nothing uses it. The identity-match constant
anchors on either envelope import.

Measured both ways: the current 3.3.0-beta.1 tree regenerates byte-for-byte
(make validate-generated), and against adcp#8547's schemas the
post-generation passes run to completion and emit
"class X(AdcpResponse, ProtocolEnvelope):" throughout, where they crashed
before.

Closes #1680

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Approve

Approve — clean build-time codegen tooling fix with no blocking or medium findings.

What I checked:

  • Only 2 files changed: scripts/post_generate_fixes.py (+142/-72) and a new 165-line test tests/test_post_generate_envelope_matchers.py. No edits to src/adcp/types/domains/**, _generated.py, aliases.py, or any public-surface export — so semver, forward-compat, and generated-code-is-not-source gates do not apply.
  • The change replaces 29 brittle exact class-signature string matches with name-based find_class_header/require_class_header lookups and derives envelope bases from the generated ProtocolEnvelope. This makes the status-alias, verify-brand-claim, and compatibility-enum passes robust to an adcp#8547 base-list change instead of silently skipping — a fail-closed improvement (missing class now raises a named RuntimeError rather than silently no-op).
  • Output is byte-for-byte identical on the current 3.3.0-beta.1 tree; no CI gate disabled, no test silenced, no credential/ctx_metadata or import-layering concern. New tests cover both pre- and post-8547 compositions.

Gate checks: high_risk=false; gated_paths=false; no no-auto-approve team match; no prior decision. No critical/high/medium findings. Falls through decision table to row 9.

This branch has not been deployed

No deployments
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