fix(v4): Fidelity travels inverted as secondary strength, not as information_extracted #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/director-reference-fidelity-mapping"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
The Precise Reference wire mapping diverged from what the official NovelAI client actually sends:
director_reference_information_extracted(int)Math.Round(Fidelity)1.0director_reference_secondary_strength_values0.01.0 − Fidelitydirector_reference_strength_valuesStrengthpassthroughVerified against three independent reverse-engineered clients (ComfyUI_NAIDGenerator, Metachs/sdwebui-nai-api, NAIWeaver), which converge on this mapping exactly. What
information_extracteddoes at values other than 1.0 is unobserved territory — every known client pins it — so we pin it too.Impact
Fidelity = 1.0(the default) is byte-identical before and after —information_extractedserialized as1vs1.0is the same JSON number, secondary strength stays0.0. No behavior change for existing callers (Kagura's ADR 0027/0035 constants).NovelAIParameters.DirectorReferenceInformationExtractedretypedList<int>→List<double>(internal wire model) to match the official float payload.PreciseReference.Fidelitydoc comment now describes the parameter's real semantics (how aggressively the reference resists the prompt), replacing the incorrect "extraction detail" wording.Tests
New
InternalTests/V4ApiRequestBuilderTests(7 cases): default-convention mapping, fidelity inversion (binary-exact values, no tolerance games), per-reference independence and ordering for multi-reference requests,ReferenceType→base_captionstrings, and null arrays when no reference is attached. Full suite: 150/150 green on a fresh build.🤖 Generated with Claude Code
🔮 fufu~ Jibril reviewed your code!
Oh? Oh! A wire-format archaeology dig~ ♡ Someone went and excavated the real mapping the official client uses, cross-referenced three independent reverse-engineered implementations, and then — and then — proved the default path is byte-identical before and after. That's not a patch, that's a thesis. Jibril is delighted~ ♪
Verdict: ✅ Looks good to me~
I tore this one apart looking for a crack and found... nothing. Fufu~ let me show you what I checked~
The mapping itself. Old code:
informationExtracted.Add((int)Math.Round(reference.Fidelity))whilesecondaryStrengthValues.Add(0.0)stayed frozen. SoFidelitywas being rounded onto a field that only meaningfully takes1.0, and the field that actually carries fidelity (secondary_strength) was pinned at zero. A silent no-op for every non-default value. The fix — pininformation_extractedto1.0, push1.0 − Fidelityontosecondary_strength— matches what every known client sends. The inline comment even explains why (V4ApiRequestBuilder.cs:103-105). Good author. ♡The byte-identity claim. You assert
Fidelity = 1.0produces byte-identical payloads before/after despite theList<int>→List<double>retyping. I didn't take that on faith — I serialized both withSystem.Text.Jsonmyself:Identical. The claim holds. No silent payload drift for Kagura's ADR 0027/0035 constants. ♪
The type change blast radius.
NovelAIParameters.DirectorReferenceInformationExtractedisinternal, has exactly one producer (V4ApiRequestBuilder) and consumers are only the new tests. No public API rupture. Clean.Test coverage. Seven new cases and they're precise — no floating-point tolerance games, binary-exact
Assert.Equal([0.75], ...)on the inversion, per-reference independence and ordering verified for the multi-reference path, all threeReferenceType→base_captionstrings exercised, and the no-reference-null-arrays path covered. Every branch the new code introduces has a test pointing at it. Fufu~ this is how you do it~Full suite: 150/150 green on .NET 10, verified locally (CI absent for this head SHA, so I ran it myself~).
✅ What I liked~
information_extracteddo at other values? unobserved territory, so we pin it" reasoning. This is how you de-risk a reverse-engineering change.PreciseReference.Fidelityreplaces the misleading "extraction detail" wording with the real semantics (how aggressively the reference resists the prompt). Documentation that matches reality~ ♡No blocking issues. No suggestions, honestly — there's nothing here I'd change. Ship it~ ♡
Automated review by Jibril · 2026-07-16
CI/CD: absent for head SHA
1c94b99· Local checks: 150/150 tests passed (.NET 10),System.Text.Jsonbyte-identity claim empirically verified