Skip to content

Commit 60d53eb

Browse files
committed
docs: add findings to CONSTRUCTOR_UNION_FAILURE_INVENTORY.md from adversarial review
1 parent 42b09dc commit 60d53eb

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

CONSTRUCTOR_UNION_FAILURE_INVENTORY.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,22 @@ Do not call the feature done until each item is:
125125

126126
## Open Items Under Active Audit
127127

128-
- Symmetry between constructor-form unions and named/declaration-form unions beyond the covered service/transform cases.
129-
- Remaining edge cases for custom discriminator/value keys beyond the covered HTTP/OpenAPI example paths.
130-
- Post-normalization identifier collisions in generated Go/OpenAPI helper names beyond the covered discriminator-name cases.
131-
- Multipart and broader streaming/security-analysis behavior for constructor unions beyond the covered WebSocket and method-validation paths.
132-
- Broader gRPC coverage beyond the covered unary and bidirectional-streaming smoke paths.
133-
- Anonymous-union deduping and helper/type collisions across repeated use sites beyond the covered same-service repeated-use and collection-transform paths.
134-
- Whether silent omission is the right upstream contract for ambiguous union examples, or whether the generator should preserve the raw example or raise a design-time error instead.
135-
- Whether rejecting defaults on all unions is an intentional upstream contract change or constructor-union-specific behavior that widened unintentionally.
136-
- Duplication of constructor-union naming/stability logic across DSL, expr finalization, and transport codegen, which increases drift risk.
128+
- [ ] **Package-level constant collision in `KindConst` generation**: In `codegen/service/service_data.go`, `KindConst` is generated by concatenating `kindName` and `fieldName` without verifying the resulting name's uniqueness in the package scope. This can lead to collisions between different unions or other package-level identifiers (e.g., Union `Foo` with branch `KindBar` vs Union `FooKind` with branch `Bar`).
129+
- [ ] **Ambiguous OpenAPI example matching in `objectExampleMatchScore`**: In `http/codegen/openapi/v3/example.go`, `objectExampleMatchScore` does not check for required fields. An empty object example `{}` will match any object branch with a score of 1, potentially leading to unintended ambiguity or silent omission of examples for unions where one branch has required fields and another does not.
130+
- [ ] **Primitive type resolution in `OneOf` constructor string variants**: In `dsl/attribute.go`, `resolveOneOfVariantType` for string variants only checks for `UserType`. Passing primitive names like `"int"` or `"string"` results in a forward-reference to a non-existent `UserType`, failing later in validation instead of resolving to the built-in primitive types.
131+
- [ ] **`InvalidOneOf` sentinel leaked to codegen**: The `InvalidOneOf` sentinel type used in `dsl/attribute.go` for failed `OneOf` declarations is not explicitly filtered or handled in service or transport codegen layers. While DSL evaluation errors should prevent codegen, a partial or ignored error state could lead to uncompilable or nonsensical code being generated for an "InvalidOneOf" type.
132+
- [ ] **Duplicated naming/stability logic drift risk**: The logic for building `bases` and `stableKeys` for `UniqueStableNames` is duplicated between `expr/union_naming.go` (`DerivedUnionVariantNames`) and `codegen/types.go` (`UniqueUnionFieldNames`). This increases the risk of behavioral drift where DSL-time discriminator naming and codegen-time field naming become inconsistent over time.
133+
- [ ] **Aggressive `strings.TrimRight` in OpenAPI `uniquify`**: In `http/codegen/openapi/v3/types.go`, the `uniquify` method uses `strings.TrimRight(n, "0123456789")` which is too aggressive if a type name naturally ends in a number (e.g., `IPv6` -> `IPv`). This can cause unexpected collisions or naming shifts when uniquifying such types.
134+
- [ ] Symmetry between constructor-form unions and named/declaration-form unions beyond the covered service/transform cases.
135+
- [ ] Remaining edge cases for custom discriminator/value keys beyond the covered HTTP/OpenAPI example paths.
136+
- [ ] Post-normalization identifier collisions in generated Go/OpenAPI helper names beyond the covered discriminator-name cases.
137+
- [ ] Multipart and broader streaming/security-analysis behavior for constructor unions beyond the covered WebSocket and method-validation paths.
138+
- [ ] Broader gRPC coverage beyond the covered unary and bidirectional-streaming smoke paths.
139+
- [ ] Anonymous-union deduping and helper/type collisions across repeated use sites beyond the covered same-service repeated-use and collection-transform paths.
140+
- [ ] Whether silent omission is the right upstream contract for ambiguous union examples, or whether the generator should preserve the raw example or raise a design-time error instead.
141+
- [ ] Whether rejecting defaults on all unions is an intentional upstream contract change or constructor-union-specific behavior that widened unintentionally.
142+
- [ ] Duplication of constructor-union naming/stability logic across DSL, expr finalization, and transport codegen, which increases drift risk.
143+
137144

138145
## Priority Tests To Add
139146

0 commit comments

Comments
 (0)