Repository navigation
fix: refuse a value-object contract declared through an interface or a base record - #204
Merged
CaffeinatedCoder merged 1 commit intoOct 30, 2026
Conversation
…a base record
IValueObject<,>, IValueObjectMaterializer<,> and IPlainValueObject<,>
are implemented by the generators with OverrideStrategy.Fail, and
declaring one on the value object is CMTK1011. Declared through an
interface of the user's, as an IEntityId<TSelf> : IValueObject<TSelf,
Guid> written to constrain generic code, or by a base record, the
aspect failed instead (LAMA0512, and LAMA0041 for the materializer),
naming nothing the user wrote: GeneratedMembersDeclaredByHand read the
value object's directly declared interfaces alone.
It now reads each declared interface's own interfaces and each base
record's, and names where the contract comes from ("the interface
IValueObject<OrderId, Guid> in its interface IEntityId<OrderId>", "...
in its base type X"), with IConvertible folded into the same check.
Neither marker derives from a contract, so an interface derived from a
marker stays allowed. Only builds that failed before fail, now with a
CMTK error. Decision 121 records refusing over accepting the contract
through an interface, which would add behaviour to a patch.
Input class (GTS): a contract the generators implement, by where it is
declared. Catalogue: IValueObject one and two interfaces down, through a
base record's interface and through a library interface;
IValueObjectMaterializer and IPlainValueObject through an interface; and
an interface derived from the marker, which builds. IConvertible's rows
hold the folded check.
Reverting the source fails the 6 new rows and the two LAMA guards (8 of
294 BuildOutcomeTests); dropping the interface or the base read fails
its rows; counting the marker as a contract refuses every value object.
Refs #192
Defect-Class: GTS
Found-By: VA
Co-Authored-By: Claude Opus 5.5 <[email protected]>
CaffeinatedCoder
deleted the
fix/value-object-contract-through-interface-refused-2-3-1
branch
October 30, 2026 21:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #192
Problem
The generators implement
IValueObject<,>,IValueObjectMaterializer<,>andIPlainValueObject<,>withOverrideStrategy.Fail, and declaring one on the value object is CMTK1011. Declared any other way, the aspect failed with a Metalama error that names nothing the user wrote. That covers an interface of the user's (one interface down or two, this project or another) and a base record. The errors were LAMA0512, plus LAMA0041 for the materializer.ValueObjectDeclaration.GeneratedMembersDeclaredByHandread only the interfaces the value object declares directly.Change
GeneratedMembersDeclaredByHandnow also reads each declared interface's own interfaces, and each base record's interfaces. It names where the contract comes from: "the interface IValueObject<OrderId, Guid> in its interface IEntityId", or "… in its base type X".IConvertibleis folded into the same check, with unchanged messages.IValue<T>,IValidatedValue<,,>) derives from a contract, so an interface derived from a marker stays allowed.Valuewould implement: that would add behaviour to a patch, for a constraintIValueObject<TSelf, T>itself serves.IValueObject<TSelf, T>. That sentence was already promising "declared directly or through another interface". ClaimC22-a-contract-through-an-interfaceholds it. The 2.3.1 changelog anddesign/aspects.mdfollow.Tests
BuildOutcomeTests(294):An_interface_s_explicit_implementation_of_a_generated_interface_is_refused_by_name.IValueObjectone and two interfaces down, through a base record's interface, and through a library interface (the fixture's generator-free library).IValueObjectMaterializerandIPlainValueObjectthrough an interface.A_marker_declared_through_an_interface_is_generatedpins that a marker-derived interface still builds.Reverted (
verify-the-guard):release/2.3.1Every_error_is_one_of_the_intended_onesandNested_value_objects_...(LAMA)IConvertibleones, plus the LAMA guardsContractThroughBaseInterface, the 3IConvertiblebase rows, plus the LAMA guardsProbesis refusedVariants. Input class GTS: a contract the generators implement, by where it's declared (the value object, an interface one or two down, a library's interface, a base record) and which contract.
🤖 Generated with Claude Code