Skip to content

Fix non-deterministic key ordering in generated MCPG config#328

Merged
jamesadevine merged 1 commit intomainfrom
copilot/fix-key-ordering-issue
Apr 27, 2026
Merged

Fix non-deterministic key ordering in generated MCPG config#328
jamesadevine merged 1 commit intomainfrom
copilot/fix-key-ordering-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 27, 2026

The MCPG config JSON embedded in compiled pipelines had non-deterministic key ordering, causing intermittent ado-aw check integrity failures where servers like safeoutputs and azure-devops would swap positions across runs.

Root cause: McpgConfig.mcp_servers and McpgServerConfig.{headers, env} were HashMap<String, _>. serde_json serializes HashMap in iteration order, which Rust's RandomState randomizes per-process — so the same source compiled to byte-different JSON.

Changes

  • Switch the three serialized maps to BTreeMap<String, _> so JSON key order is sorted and stable.
  • Update nonempty_map to convert HashMapBTreeMap at the serialization boundary (input front-matter maps stay HashMap).
  • Update try_add_user_mcp parameter and the accumulator in generate_mcpg_config.
  • Update BTreeMap::from(...) constructions in extensions/safe_outputs.rs and tools/azure_devops/extension.rs.

@jamesadevine jamesadevine marked this pull request as ready for review April 27, 2026 14:23
@jamesadevine jamesadevine merged commit 889ee62 into main Apr 27, 2026
@jamesadevine jamesadevine deleted the copilot/fix-key-ordering-issue branch April 27, 2026 14:24
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.

2 participants