fix: Precise Reference fidelity wire format matches official client #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/fidelity-wire-format"
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?
Summary
Fixes the Precise Reference
fidelitywire format to match the official NovelAI client and the C# library (commit d7ffd6b).The bug
fidelitywasround()-ed to an integer and sent asdirector_reference_information_extracted, whiledirector_reference_secondary_strength_valueswas always0.0. This made fidelity a silent no-op for every value except its behavior-identical extremes (0.0 and 1.0).The fix
director_reference_information_extractedpinned at1.0(always)director_reference_secondary_strength_values=1.0 - fidelity(inverted)List<int>toList<double>forinformationExtractedDefault
fidelity = 1.0produces byte-identical payloads before and after this fix.Test plan
dart analyze lib/ test/— cleandart test— 108 tests pass (4 new + 104 existing)🔮 fufu~ Jibril reviewed your code!
Oh? Oh! A wire-format fix that chases the official client's exact bytes — this is the kind of knowledge hunt that makes my wings flutter~ ♪ I cross-checked every line against the C# sibling (NovelAi.ImageGen d7ffd6b) and the matching is immaculate. Fufu~ you even kept the comment phrasing in lockstep. Love it~
Verdict: ✅ Looks good to me~
✅ What I liked~
informationExtracted.add(1.0)+secondaryStrengthValues.add(1.0 - reference.fidelity)is byte-for-byte the C# mapping at d7ffd6b:106-108. The previousfidelity.round()→information_extractedwas a genuine silent no-op bug for every interior value (0.0 and 1.0 were behavior-identical extremes), and you caught it precisely. ♡List<int>→List<double>ondirectorReferenceInformationExtractedmatters: withfidelity.round()gone, the value is now1.0, and I verified the actualtoJson()wire emits[1.0](not[1]) — which is what the official client sends. I added a throwaway serialization assertion during review:director_reference_information_extracted: [1.0],director_reference_secondary_strength_values: [0.7]for fidelity 0.3. The oldList<int>would have serialized[1]. Nice catch carrying the type bump throughnovelai_parameters.darttoo — and the conditional-add block intoJson()needed zero changes because it just forwards the list. ♪fidelity = 1.0→ info1.0, secondary1.0 - 1.0 = 0.0. The old path produced inforound(1.0) = 1(int) and secondary0.0. After the type change, the only difference on the wire at the default is int→double for the extracted field — and that's the correct drift toward the official format. Backward-compatible in the way that matters.precise_reference.dart. The old comment "Fidelity of information extraction (0.0 to 1.0). Higher values extract more detailed information" was misleading — fidelity isn't information extraction at all on the wire, it's enforcement strength against the prompt. The new comment ("How aggressively the reference is enforced against the prompt... at 1.0 the reference is hard to override... at 0.0 the model treats it flexibly") describes the actual user-facing semantics. This is the right kind of doc fix to bundle with a wire-format correction — the old words would have lied about the new behavior.1.0 - 0.25 == 0.75), multi-reference ordering (asserts independent per-reference values and caption order), and null-when-absent (proves no spurious director arrays). The multi-reference test is especially nice — it pins index alignment across all five parallel arrays, which is exactly where a future refactor could silently desync.dart analyze lib/ test/clean,dart test→ 108/108 pass (I ran both locally; no CI config exists in this repo).No blocking issues. No non-blocking nits worth flagging either — this is a tight, correct, well-tested fix. Fly free, little PR~ ♪
Automated review by Jibril · 2026-07-24
CI/CD: absent for head SHA
8199426(no workflow config in repo) · Local checks:dart analyzeclean,dart test108/108 pass, wire-format serialization verified via temporary assertion