Skip to content

refactor: Rename ShapeRef to MemberShape and add target abstraction for SERDE traversal#342

Open
jterapin wants to merge 22 commits into
decaffrom
shape-ref-rework
Open

refactor: Rename ShapeRef to MemberShape and add target abstraction for SERDE traversal#342
jterapin wants to merge 22 commits into
decaffrom
shape-ref-rework

Conversation

@jterapin
Copy link
Copy Markdown
Contributor

@jterapin jterapin commented Jun 4, 2026

Summary

Renames ShapeRef back to MemberShape and introduces a uniform target abstraction so codecs can traverse member and non-member shapes the same way. Mechanical/structural only — no behavior change. Trait-resolution improvements are deferred to a follow-up PR. Aligns the shape model with Smithy's own vocabulary (the spec's member shape concept and the target key in the Smithy AST

Key changes

Rename + target abstraction

  • ShapeRefMemberShape; .shape/@shape.target/@target.
  • Shape#target returns self, so a bare shape and a MemberShape both respond to
    .target. Codecs dispatch on node.target uniformly — no wrapper needed at the root.

Operation slots are bare shapes

  • operation.input, output, and errors now store the targeted StructureShape
    directly (no-input ops resolve to Prelude::Unit) instead of a MemberShape wrapper.
    Consumers read through .target (which is self for a shape), so nothing breaks.

Codec rework (JSON, CBOR, XML)

  • Dropped the shape.is_a?(MemberShape) ? shape : MemberShape.new(...) entry wrapper.
  • Dispatch on shape.target; renamed the dispatch methods to build_shape/parse_shape
    to align with the Builder/Parser entry points.
  • XML DocBuilder output buffer renamed @target@output (avoids colliding with the
    shape target concept); parser accumulator named result.

Schema codegen view cleanup

  • Extracted a shared SchemaHelper (shape-id → constant resolution + prelude map);
    collapsed duplicated build_members; removed dead duplication.

document_utils Serializer / Deserializer

  • Same wrapper-drop + serialize_shape/deserialize_shape dispatch.

RBS + repo-wide cleanup

  • Updated shapes.rbs (Shape#target, input/output/errors as Shape) and each
    codec's codec.rbs.
  • Swept the repo for residual ref/shape_ref/member_ref vocabulary in runtime
    consumers (plugins, handlers, stubbing, param helpers) and specs.

Downstream impact

Once merged, aws-sdk-ruby-staging (version-4) needs corresponding updates: code that
reads operation.input.shape / member.shape must move to .target, and protocol
error-handling that referenced the old accessors needs the .shape.target change.
Validated against the staging protocol tests during development.

Regenerated

  • projections/weather and projections/shapes.

@jterapin jterapin changed the title [DRAFT] refactor: Rename ShapeRef to MemberShape and add target abstraction for SERDE traversal refactor: Rename ShapeRef to MemberShape and add target abstraction for SERDE traversal Jun 5, 2026
@jterapin jterapin marked this pull request as ready for review June 5, 2026 16:27
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