fix(json-cppagent): drop JsonConditionsConverter; list-derived shape - #208
Draft
ottobolyos wants to merge 2 commits into
Draft
fix(json-cppagent): drop JsonConditionsConverter; list-derived shape#208ottobolyos wants to merge 2 commits into
ottobolyos wants to merge 2 commits into
Conversation
ottobolyos
force-pushed
the
fix/jsonconditions-structural-rewrite
branch
from
July 22, 2026 19:09
5af1437 to
e26e9ff
Compare
ottobolyos
force-pushed
the
fix/jsonconditions-structural-rewrite
branch
from
July 22, 2026 19:17
e26e9ff to
4d19791
Compare
…ers surface (RED)
Adds JsonConditionWrapperTests and rewrites JsonConditionsArrayShapeTests
to pin the cppagent JSON v2 array-of-single-key-wrappers wire shape via
the new JsonConditionWrapper + list-derived JsonConditions surface that
the following fix commit introduces.
New coverage in JsonConditionWrapperTests (24 tests):
* Four Of{Fault,Warning,Normal,Unavailable} factory contracts
(each populates exactly one level, others null).
* Value accessor: null on empty, correct return for each of the four
single-populated levels, and Fault > Warning > Normal > Unavailable
precedence on multi-populated wrappers.
* Level accessor: null on empty, correct wire-property-name return
for each of the four single-populated levels.
* ToObservation materializer: null on empty, correct level enum
for each of the four single-populated levels.
* Wire envelope serialization: single-key output under sparse
options, convenience-accessor suppression, empty-wrapper -> {},
multi-populated documentation.
* Per-envelope deserialization: each of the four single-key inputs
populates the matching property and leaves the other three null.
Rewritten JsonConditionsArrayShapeTests (23 tests):
* Three ctors covered: default (empty), copy-from-wrappers (insertion
order preserved), and IEnumerable<IObservationOutput> (null-arg /
empty / level-order emission / null-entry-skip).
* Observations computed accessor: empty container, materialization
in insertion order across all four levels, empty-wrapper skip.
* Wire shape: [] on empty, single Normal wrapper, insertion order
preserved across mixed levels, observation-ctor Fault-Warning-
Normal-Unavailable level order, mixed-level array deserialization
populates the correct wrapper property, round-trip byte-identical,
root null <-> "null".
This commit is compile-error RED per CONVENTIONS §1.0d-vicies-semel:
the tests reference JsonConditionWrapper, the list-shape JsonConditions,
and the AmE parameter names / XML-doc verbs that all land in the
following fix commit.
Claude-Session: https://claude.ai/code/session_015FLSuNX8hZPFiTGtE8GYqH
Deletes JsonConditionsConverter (~200 lines) and rewrites
JsonConditions as List<JsonConditionWrapper>-derived so the type
shape IS the wire shape. System.Text.Json's default serializer
handles both directions with no custom converter code.
New shape:
* JsonConditions : List<JsonConditionWrapper> — three ctors:
parameterless, copy-from-wrappers, and IEnumerable<IObservationOutput>
which preserves the historical Fault -> Warning -> Normal ->
Unavailable level-order emission for byte-compatible wire output
against the pre-refactor converter under sparse serialization
options.
* JsonConditionWrapper — four nullable level properties with
[JsonIgnore(WhenWritingNull)] for the single-key envelope,
Value / Level convenience read-side accessors, ToObservation
materializer, and OfFault / OfWarning / OfNormal / OfUnavailable
factories.
Deletions:
* JsonConditionsConverter.cs — the entire class.
* [JsonConverter(typeof(JsonConditionsConverter))] attribute on
JsonConditions.
Behavioral changes (intentional at 7.0 major-bump window):
* Legacy MTConnect JSON v1 object-keyed READ compat is dropped.
The default List<T> deserializer only reads arrays; the pre-7.0
fallback to {"Fault":[...], "Warning":[...]} envelope is removed.
* Mixed-level wire interleaving is no longer re-bucketed by level
on write — insertion order is preserved end-to-end. Producers
wanting the historical grouping can use the IEnumerable<
IObservationOutput> ctor or sort explicitly.
* Strict malformed-wrapper rejection with named JsonException
messages is dropped; default S.T.J tolerance applies.
Turns the RED tests from the preceding commit GREEN:
47/47 on JsonCondition* filter; 391/391 on the full
MTConnect.NET-JSON-cppagent-Tests suite (bluefin net8.0).
Closes dime-connector bug report TrakHound#15 on the mtc.net upstream side.
Claude-Session: https://claude.ai/code/session_015FLSuNX8hZPFiTGtE8GYqH
ottobolyos
force-pushed
the
fix/jsonconditions-structural-rewrite
branch
from
July 23, 2026 18:10
4d19791 to
74b8749
Compare
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
Closes the ~200-line hand-written
JsonConditionsConverterand rewritesJsonConditionsasList<JsonConditionWrapper>-derived so the type shape IS the cppagent JSON v2 wire shape. System.Text.Json's default serialiser handles both directions with no custom converter — round-trip is symmetric by construction, no reader-state edge cases to defend against, and the wire is byte-compatible with the pre-refactor output when the emission pipeline uses the same sparse-serialisation options.Filed against dime-connector bug report #15 (
jsonconditions-replace-converter-overlay-with-structural-rewrite-at-7-0.md); this is the mtc.net upstream side of that follow-up to #12 (v1 → v2 wire-shape fix). Targeted at the 7.0 major-bump window so the API-break window is already open.Change
JsonConditionWrapper(libraries/MTConnect.NET-JSON-cppagent/Streams/JsonConditionWrapper.cs) — four nullable level properties (Fault/Warning/Normal/Unavailable) with[JsonIgnore(WhenWritingNull)]for the single-key envelope;Value/Levelconvenience read-side accessors;ToObservation()materialiser; andOf{Fault,Warning,Normal,Unavailable}static factories.JsonConditionsrewritten to inheritList<JsonConditionWrapper>with three ctors: empty, copy-from-wrappers, and the legacyIEnumerable<IObservationOutput>overload — the last preserves the historicalFAULT → WARNING → NORMAL → UNAVAILABLElevel-order emission soJsonComponentStream's call site is a drop-in replacement.JsonConditionsConverterdeleted — the entire class.Behavioural changes (intentional at 7.0)
List<T>deserialiser only reads arrays; the pre-7.0 fallback to{"Fault":[…], "Warning":[…]}envelope is removed. #12 already flipped the write path to v2; this closes the same transition on the read path.IEnumerable<IObservationOutput>ctor (unchanged) or sort explicitly before construction.JsonExceptionmessages is dropped. Default S.T.J tolerance applies; malformed input produces default S.T.J errors instead of custom prose.Test plan
dotnet test tests/MTConnect.NET-JSON-cppagent-Tests/ --filter "FullyQualifiedName~JsonCondition"— 47/47 GREEN (bluefinnet8.0verified56c61e9a).JsonConditionWrapperTests(24 tests) — factory contracts,Value/Levelprecedence (Fault > Warning > Normal > Unavailable),ToObservationmaterialisation at each level + empty, wire envelope serialisation, per-envelope deserialisation.JsonConditionsArrayShapeTests(23 tests) — three ctors (default, copy, observation-sequence with null / empty / level-order / null-entry-skip),Observationsaccessor (empty / insertion-order / skip-empty-wrappers), wire shape (empty array / single wrapper / insertion order preserved / observation-ctor level order / round-trip byte-identical / root null).MTConnect.NET-JSON-cppagent-Tests.csprojsuite — verified GREEN on bluefin.integration/all-fixesre-build.Commits (single):
fix(json-cppagent): replace JsonConditionsConverter with structural rewritehttps://claude.ai/code/session_015FLSuNX8hZPFiTGtE8GYqH