Skip to content

fix(core): preserve JSON null documents in inline round trips - #707

Closed
marcschier wants to merge 2 commits into
xregistry:mainfrom
marcschier:fix/spec-592-lossless-json-null
Closed

marcschier wants to merge 2 commits into
xregistry:mainfrom
marcschier:fix/spec-592-lossless-json-null

Conversation

@marcschier

@marcschier marcschier commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #592.

Proposed Changes - current review scope

This original PR remains open as policy decision (e). The approved
three-bundle consolidation does not approve or merge this proposal.

The ordinary inline round-trip loss is directly demonstrable, but the PR chooses a new mandatory output exception: nonempty JSON-null documents always use original-byte base64 even without the binary flag. Existing rules do not uniquely require that remedy.

Python cleanup in 38e7c4f

The forward, signed cleanup commit removes new specification-text assertions
and synthetic policy-test code unless it has a concrete role in checking
real repository artifacts. It does not change this PR's normative proposal,
source models, samples, generated artifacts or production behavior.

Python path Disposition
tools/test_json_null_document_592.py remove

Script-only documentation and obsolete helper/test instructions were removed
or corrected with the affected code. Unmodified baseline Python is outside
the audit's scope; the cleanup is not evidence that a proposed policy is
already normative.

Current evidence and dependencies

  • Full baseline tools suite: python -B -m pytest tools -q --tb=short -p no:cacheprovider -p pytest_asyncio.plugin: 67 passed; 4 existing deprecation warnings.
  • Exact cleanup scope, retained blob preservation, removed-helper references, whitespace, direct-parent ancestry and author-matching sign-off were verified.

This PR is not superseded by the three a/b/c bundles and must remain open for the review scope above.

The cleanup preserves the original draft state. No review thread is marked
resolved by this update, and no source branch is deleted. The historical
description below is preserved for context; its old test counts, helper
instructions and specification-text assertions are not current evidence.

Historical description at 88855d7 (before cleanup)
Fixes #592.

## Change and compatibility

Require `<RESOURCE>base64` with the original bytes when a nonempty document would otherwise be emitted as the JSON value `null`. The exception applies to ordinary JSON output and JSON typemap selection without requiring the binary flag. Include a Core example using `bnVsbA==`, and limit JSON pretty-print permission to the inline JSON form.

The existing explicit-null write operation is unchanged: null on any of the three document fields still requests an empty document. JSON string `"null"`, false, zero, empty strings/structures, and nested null values are not treated as top-level JSON-null documents. This is an output field-choice correction within existing supported alternatives, separate from the string/typemap precedence fix in #699.

## Evidence

| Requirement | Focused regression |
| --- | --- |
| Store/export/import without binary opt-in | `test_json_null_store_export_import_needs_no_binary_flag` |
| Exact null bytes and surrounding JSON whitespace under default, JSON-typemap and binary modes | `test_json_null_bytes_round_trip_in_every_output_mode` |
| Empty bytes remain distinct from a null document | `test_empty_document_is_distinct_from_json_null_in_every_mode` |
| JSON string null, false, zero, empty structures and nested null retain their values and kinds | `test_json_string_null_and_other_falsy_values_are_not_reset`, `test_nested_null_is_not_a_top_level_null_document` |
| Explicit request-null reset and absent-field preservation | `test_explicit_request_null_still_resets_every_document_field`, `test_absent_document_fields_and_unrelated_null_leave_bytes_unchanged`, `test_source_request_null_reset_rule_is_preserved` |
| Actual Core example and JSON-typemap exception | `test_core_null_document_example_round_trips_the_original_bytes`, `test_model_json_mapping_has_an_explicit_null_exception` |

The pre-fix abstract round trip reproduced the exact loss, `b'null'` becoming `b''`: 12 failures and 47 passing cases before the correction. Final focused run: 59 passed. Full `python -B -m pytest tools -q --tb=short -p no:cacheprovider -p pytest_asyncio.plugin`: 126 passed, with the four existing OpenAPI deprecation warnings unchanged. All three actual changed Markdown documents passed repository verification functions; isolated spell/tab checks, LF checks, and staged/committed diff checks passed.

## Limits

This is executable source-example and abstract document-field evidence, not live server or SDK conformance. The helper receives resolved JSON/binary selections and UTF-8 examples; it does not implement typemap matching, string encoding, model admission, document retrieval, or complete requests. It does not require exact bytes for every ordinary non-null JSON write. Helper links and explanations are confined to the adjacent issue-specific tools README.

The independent branch starts at `9ecf8ea67bc9a6128c154b4545a21164493cc71e` and contains no other issue's fix.

Use the supported base64 form for a nonempty document whose JSON representation would be null, including JSON typemap selection without the binary flag. Keep explicit request-null reset and other JSON value kinds unchanged, and preserve the original null-document bytes.

Signed-off-by: Marc Schier <marcschier@hotmail.com>
@marcschier
marcschier marked this pull request as ready for review September 15, 2026 12:53
Remove the approved toy document import/export tests and script-only README. Preserve every Core and Model hunk for the separate JSON-null representation policy review.

Signed-off-by: Marc Schier <marcschier@hotmail.com>
@marcschier

Copy link
Copy Markdown
Contributor Author

Applied signed, forward cleanup commit 38e7c4f. Removed the introduced specification-text/synthetic-policy Python and its script-only instructions. The full remaining baseline tools suite passed 67 cases.

The normative proposal, source models, samples and generated artifacts are unchanged by cleanup. This PR remains open for its e review; no policy decision or review-thread resolution is implied.

Updated the PR description with current evidence, explicit retained scope and the pre-cleanup description archived as historical context. Original draft state and source branch are preserved.

marcschier added a commit to marcschier/xregistry-drafts that referenced this pull request Sep 16, 2026
Retain category e typemap precedence over discretionary base64 and the proposed lossless string fallback without choosing a universal character encoding. The established string/json/binary, implicit-map, binary-flag and empty-document alignment retains category b ownership in xregistry#723. Keep that required overlap until its actual upstream merge; do not merge the whole prerequisite branch. The next source commit composes xregistry#707 decoded-null exception.

Source-PR: xregistry#699
Source-Head: 9d29755
Source-Merge-Base: 9ecf8ea
Source-Commit: 9668fa6
Prerequisite-Owner: xregistry#723 (established document representation alignment)
Signed-off-by: Marc Schier <marcschier@hotmail.com>
marcschier added a commit to marcschier/xregistry-drafts that referenced this pull request Sep 16, 2026
Retain the reviewed category e original-byte base64 exception for decoded JSON null, even without the binary flag, and leave request-null reset, nested null and the JSON string null unchanged. Qualify xregistry#699 generic mapping statements with this existing exception in Core and Model; its base64 description now refers to all representation rules. This is source composition, not a new encoding policy.

Source-PR: xregistry#707
Source-Head: 38e7c4f
Source-Merge-Base: 9ecf8ea
Source-Commit: 88855d7
Composed-With: xregistry#699 (9d29755)
Signed-off-by: Marc Schier <marcschier@hotmail.com>
@marcschier

Copy link
Copy Markdown
Contributor Author

Superseded by the expanded Core model and Resource semantics keeper xregistry/spec#677. The reviewed net changes at 38e7c4f were transferred with their issue and review provenance; specification-text/synthetic-policy Python stays removed.

Transfer and local integration evidence are in the keeper provenance comment. Immediately before closing, keeper head ac0abc5 had successful verify and DCO gates.

Closing this original only as superseded: the policy decisions remain open in the keeper, no upstream merge or review-thread resolution is implied, and the source branch is preserved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve a JSON null document through ordinary inline round-trips

1 participant