Skip to content

fix: sort resource collections in YAML and register fetch command - #291

Merged
Ruari-Phipps merged 2 commits into
mainfrom
ruari/fix/condition_ordering
Aug 28, 2026
Merged

fix: sort resource collections in YAML and register fetch command#291
Ruari-Phipps merged 2 commits into
mainfrom
ruari/fix/condition_ordering

Conversation

@Ruari-Phipps

@Ruari-Phipps Ruari-Phipps commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Sorts collections alphabetically during YAML serialization so pulls produce stable, diff-friendly output. Also registers FetchCommand in the CLI command list — it was implemented but never wired up, so poly fetch was unavailable.

Motivation

Several collections are built by iterating a map in the platform projection — flow step conditions, API integration operations, test case function call assertions and their arguments, and the integration/operation keys of test case API mocks. Their serialized order followed whatever the map iteration gave, so unrelated pulls could reorder blocks in a resource's YAML and create noisy diffs.

Separately, the fetch command existed in cli_commands/sync.py but was missing from COMMANDS, so it never appeared in the CLI.

Changes

  • FlowStep.to_yaml_dict sorts conditions by name (matches the existing sorted(self.extracted_entities) behaviour)
  • ApiIntegration.to_yaml_dict sorts operations by name
  • FunctionCallAssertion.to_yaml_dict sorts arguments by parameter_name, and TestCaseAssertion.to_yaml_dict sorts function call assertions by name
  • TestCaseApiMocks.to_yaml_dict sorts integration and operation names; the rules within an operation keep their order, since they are a sequence and repeat depends on it
  • Add FetchCommand to the COMMANDS list in cli.py so poly fetch is registered
  • Add unit tests covering each ordering, including one asserting mock rule order is preserved
  • uv.lock version bump picked up from the 0.44.4 release

Test strategy

  • Added/updated unit tests
  • Manual CLI testing (poly --help now lists fetch)
  • Tested against a live Agent Studio project
  • N/A (docs, config, or trivial change)

Checklist

  • ruff check . and ruff format --check . pass
  • pytest passes (1356 passed)
  • No breaking changes to the poly CLI interface (or migration path documented)
  • Commit messages follow conventional commits

Screenshots / Logs

$ uv run poly --help | grep fetch
    fetch               Fetch the latest project state from Agent Studio

Sort conditions alphabetically by name when serializing a default step
so pulls produce stable YAML instead of ordering that follows whatever
the platform returns.

Also register FetchCommand in the CLI command list — it was implemented
but never wired up, so `poly fetch` was unavailable.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Ruari-Phipps
Ruari-Phipps requested a review from a team August 27, 2026 10:05
@github-actions

This comment has been minimized.

Sort API integration operations, test case function call assertions and
their arguments, and the integration/operation keys of test case API
mocks when serializing. All of these are built from platform projection
maps, so pulls previously produced whatever order the map iteration gave
and unrelated pulls reordered blocks in the YAML.

The rules within a mocked operation are left alone — they are a sequence
and `repeat` depends on their order.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Ruari-Phipps Ruari-Phipps changed the title fix: sort flow step conditions and register fetch command fix: sort resource collections in YAML and register fetch command Aug 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report

Base (main) PR Change
75.9% 75.9% +0.0% ✅

Changed file coverage

File Coverage Change
poly/cli_commands/sync.py 63.8% +1.5% ✅

@oeisenberg oeisenberg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See it, say it, sorted

@Ruari-Phipps
Ruari-Phipps merged commit ae1c29d into main Aug 28, 2026
6 checks passed
@Ruari-Phipps
Ruari-Phipps deleted the ruari/fix/condition_ordering branch August 28, 2026 11:37
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