Skip to content

Commit dc4d7ae

Browse files
committed
feat: rename @strict-numeric-typing to @numeric-coercion, and fix the rule
The tag was named for a stricter rule than the specification actually wants, and it was about to collide with a second vocabulary for the same property. flagd is implementing an accepted numeric coercion ADR (open-feature/flagd#1996) whose rule is that coercion is permitted when lossless and must fail with TYPE_MISMATCH only when information would be lost: 10.0 requested as an integer succeeds, 0.5 does not. This appendix said "does not coerce between integer and float", which forbids the case the ADR requires to work. The existing scenario survives the difference only by luck, because it asks about 0.5, which does have a fractional part. That work also introduces @numeric-coercion and @int32-bounded scenarios into flagd's own testbed. Two capability vocabularies describing one property, written in the same week, is the drift a shared vocabulary exists to prevent, so the tag takes flagd's name rather than leaving the reference implementation and the specification disagreeing about what a rule is called. Renaming now costs four draft implementations an enum change; renaming later costs a published one. Two gaps are recorded rather than closed. The lossless half of the contract has no scenario, because the canonical flag set contains no integral float to ask it of and adding one changes the flag set for every language at once -- so a provider that wrongly rejects 10.0 as an integer still passes. And accessor width is not modelled at all: the ADR distinguishes a 64-bit integer accessor from a 32-bit one, which flagd tags @int32-bounded, and that is a real source of cross-language disagreement this appendix is currently silent about. This also settles an open question on #417. @strict-numeric-typing was the one capability tracing to no numbered requirement, existing only because flagd had a defect. It now has a definition to trace to, and can stop being a known-deviation marker wearing a capability's clothes. Signed-off-by: Simon Schrottner <[email protected]>
1 parent 8454c9b commit dc4d7ae

2 files changed

Lines changed: 35 additions & 10 deletions

File tree

‎specification/appendix-f-provider-conformance.md‎

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ declares which capabilities it supports. Scenarios whose tag is not declared are
144144
| `@configuration-change` | detects configuration changes and emits `PROVIDER_CONFIGURATION_CHANGED` |
145145
| `@object` | supports structured flag values |
146146
| `@unavailable` | reports an error state instead of hanging against a dead backend |
147-
| `@strict-numeric-typing` | does not coerce between integer and float |
147+
| `@numeric-coercion` | coerces between integer and float only when lossless, else `TYPE_MISMATCH` |
148148
| `@targeting` | reserved; **not declarable** -- no scenarios yet |
149149
| `@caching` | reserved; **not declarable** -- no scenarios yet |
150150

@@ -175,13 +175,32 @@ The design rule behind this: **a conformance suite that quietly goes green on sc
175175
run is worse than no suite at all.** A TCK implementation must report unsupported capabilities as
176176
skipped and surface the reason, not silently pass or silently omit them.
177177

178-
`@strict-numeric-typing` deserves a note, because unlike the others it is **not** an optional
179-
feature. The specification requires a provider to report `TYPE_MISMATCH` when the requested type
180-
cannot be satisfied, and narrowing `0.5` to `0` to satisfy an integer request loses information
181-
silently — the worst failure mode for a feature flag, because the application sees a plausible value
182-
and no error. It is a capability only so that a provider with this defect can adopt the suite today
183-
and see the gap reported explicitly rather than being unable to adopt at all. Not declaring it is an
184-
admission of a known bug.
178+
`@numeric-coercion` deserves a note, because unlike the others it is **not** an optional feature.
179+
The specification requires a provider to report `TYPE_MISMATCH` when the requested type cannot be
180+
satisfied, and narrowing `0.5` to `0` to satisfy an integer request loses information silently — the
181+
worst failure mode for a feature flag, because the application sees a plausible value and no error.
182+
It is a capability only so that a provider with this defect can adopt the suite today and see the
183+
gap reported explicitly rather than being unable to adopt at all. Not declaring it is an admission
184+
of a known bug.
185+
186+
The rule is **lossless coercion is permitted; lossy coercion must fail**, and not the stricter "never
187+
coerce" this tag was originally named for. An integral float such as `10.0` requested as an integer
188+
must succeed; `0.5` must not. The distinction is flagd's
189+
[numeric coercion ADR](https://github.com/open-feature/flagd/blob/main/docs/architecture-decisions/numeric-coercion.md),
190+
and the tag was renamed from `@strict-numeric-typing` to match it rather than leave two vocabularies
191+
describing one property — flagd's own testbed is gaining `@numeric-coercion` scenarios, and a
192+
capability vocabulary that disagrees with the reference implementation about the name of a rule is
193+
worse than having no name for it.
194+
195+
Two gaps follow from adopting that rule, and both are open rather than fixed here:
196+
197+
- **The lossless case has no scenario.** Only the lossy half is tested, so a provider that wrongly
198+
rejects `10.0` as an integer passes. Closing it needs an integral float in the canonical flag set,
199+
which changes the flag set for every language at once.
200+
- **Accessor width is not modelled.** The ADR distinguishes the width of a language's integer
201+
accessor — Go's `ResolveIntValue` is `int64` and so is the canonical `Long`, whereas a 32-bit
202+
accessor needs its own scenarios, which flagd's testbed tags `@int32-bounded`. This appendix has
203+
nothing equivalent, and it is a real source of cross-language disagreement.
185204

186205
## Implementing the suite in a language
187206

‎specification/assets/provider-tck/gherkin/errors.feature‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Feature: Provider error handling
1414

1515
Scenario Outline: Requesting the wrong type returns the code default
1616
# The full non-numeric mismatch matrix. Numeric coercion is a separate question and is covered
17-
# by the @strict-numeric-typing scenarios below, because "is 0.5 an integer?" has a defensible
17+
# by the @numeric-coercion scenarios below, because "is 0.5 an integer?" has a defensible
1818
# wrong answer whereas "is a string a boolean?" does not.
1919
Given a <requested>-flag with key "<key>" and a default value "<default>"
2020
When the flag was evaluated with details
@@ -59,10 +59,16 @@ Feature: Provider error handling
5959
| Integer | 1 |
6060
| Float | 0.1 |
6161

62-
@strict-numeric-typing
62+
@numeric-coercion
6363
Scenario: A float flag is not silently narrowed to an integer
6464
# 'float-flag' resolves to 0.5. Narrowing that to an integer would lose information
6565
# silently, so it must be reported as a type mismatch rather than rounded.
66+
#
67+
# This is the lossy half of the coercion contract. The lossless half -- that an
68+
# integral float such as 10.0 requested as an integer MUST succeed -- has no scenario
69+
# yet, because the canonical flag set has no integral float to ask it of. Adding one
70+
# is a change to the flag set and so to every language at once; see the tag's entry in
71+
# Appendix F.
6672
Given a Integer-flag with key "float-flag" and a default value "1"
6773
When the flag was evaluated with details
6874
Then the resolved details value should be "1"

0 commit comments

Comments
 (0)