Skip to content

fix(json): preserve lexical order in typed encoding - #46

Closed
fffonion wants to merge 1 commit into
masterfrom
fix/typed-json-key-order
Closed

fffonion wants to merge 1 commit into
masterfrom
fix/typed-json-key-order

Conversation

@fffonion

Copy link
Copy Markdown
Collaborator

Summary

  • Sort object keys recursively before serializing the typed JSON projection, independent of whether a downstream crate enables serde_json/preserve_order.
  • Preserve array order and leave decoding and the explicit ordered-entry codecs unchanged.

This is the Core dependency fix for rustscript-agent#15, where the unchanged public JSON fixture observed different bytes after enabling the ACP SDK.

Verification

  • typed_json_encode_sorts_nested_object_keys failed under serde_json/preserve_order before the fix (1 selected, Cargo exit 101). The same selector passed on 540715b3 with and without that feature (1 selected and Cargo exit 0 in each run).

  • Seven focused controls passed, covering typed JSON validation, budgets, recursive schemas, optional fields, and ordered HTTP headers.

  • cargo fmt --check and git diff --check passed.

  • The unchanged Agent auth_bundle_tests target passed locally (18/18, including the original failure) using a temporary override to the exact Core candidate, with serde_json/preserve_order still enabled. This verifies the local dependency combination; the published Agent pin has not changed.

Cargo feature unification can enable serde_json preserve_order and
expose the typed encoder's map iteration order. Sort object keys
recursively just before serialization, leaving array order unchanged.

Cover nested typed objects and arrays with an exact-output regression.
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.

1 participant