test(dummies): guard Any/AnyContext mirror and builder algebra parity - #277
Merged
Conversation
Add two pure-reflection tests over the library's hand-mirrored surfaces: - Mirror parity: every scalar factory on Any has an identical AnyContext counterpart. Composition and collection factories are excluded by construction (they take an IAny<> operand and inherit the context through their operand sources). - Algebra parity: each builder exposes exactly its family's constraint method set, encoded once as an expectation table. Both are pure reflection with no per-builder maintenance beyond that table, and both fail with a named diff when a factory or a constraint method drifts on one surface but not the other. Refs: #214 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011k7zRx6Xe2UkbBLNffx5m6
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.
Summary
Add two pure-reflection tests that guard the library's two hand-mirrored surfaces against structural drift, so the accepted duplication (
Any/AnyContextand the cloned numeric/temporal builders) stays safe as new types and constraints are added.Type of change
Changes
Dummies.UnitTests/SurfaceParityTests.cswith two reflection-based guards:Anyhas an identical instance counterpart onAnyContext(same name, generic arity, parameter types, return type). Composition and collection factories are excluded by construction: they take anIAny<>operand and inherit the context through their operand sources, so they are deliberately not mirrored.Testing
dotnet build FirstClassErrors.slndotnet test FirstClassErrors.slnFirstClassErrors.Analyzers.UnitTests)All test projects pass (1411 tests, 0 failures). The two guards were verified to genuinely bite by temporarily injecting drift on each surface — an extra expected constraint name, and a removed
AnyContextfactory — confirming each fails with a named diff, then reverting.Documentation
Note: these guards are structural. The documentation-wording drift the audit noted (§4.3, e.g.
AnyContext.Guid()'s doc mentioningAny.Reproducibly) is tracked separately in #219, and true per-TFM enforcement of the netstandard2.0 surface (21 vs 26 factories) depends on the multi-target test-project work in #215 — this test currently exercises the net8.0+ surface only.Architecture decisions
The reflection-over-CRTP-base-class approach is the mitigation recommended by the 2026-07-20 Dummies architecture & design audit (§9.2); this PR implements it and records no new decision.
Related issues
Closes #214
🤖 Generated with Claude Code
https://claude.ai/code/session_011k7zRx6Xe2UkbBLNffx5m6
Generated by Claude Code