Skip to content

Unify resolver return types for consistent CLI pipeline behavior - #153

Draft
acbart with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-140
Draft

Unify resolver return types for consistent CLI pipeline behavior#153
acbart with Copilot wants to merge 3 commits into
masterfrom
copilot/fix-140

Conversation

Copilot AI commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

Resolvers in Pedal were returning inconsistent data types, causing CLI pipelines to break and requiring brittle workarounds. This PR standardizes all resolver return types to use a unified dictionary format.

Problem

Previously, different resolvers returned different data types:

  • simple.resolve() and full.resolve() returned FinalFeedback objects
  • statistics.resolve() returned a dictionary with {'final': dict, 'considered': list}
  • silent.resolve() returned an empty string
  • sectional.resolve() returned a dictionary with group mappings

This inconsistency required workaround code like:

def to_json(self):
    resolution = ({'final': self.resolution.to_json()}
                  if isinstance(self.resolution, FinalFeedback)
                  else self.resolution.copy() 
                  if self.resolution else {})

Solution

All main resolvers now consistently return the unified format:

{
    'final': final_feedback_dict,      # The chosen feedback as JSON
    'considered': [feedback_dicts]     # All considered feedback as JSON
}

This format:

  • ✅ Provides comprehensive information for analysis and debugging
  • ✅ Eliminates the need for type-checking workarounds
  • ✅ Supports the full range of capabilities mentioned in the original issue
  • ✅ Maintains backwards compatibility through consistent JSON structure

Changes Made

  • Updated resolvers: Modified simple.py, full.py, and silent.py to return the unified format
  • Removed workarounds: Eliminated isinstance checks in CLI code
  • Fixed environments: Updated terminal and standard environments to handle the new format
  • Updated tests: Modified resolver tests to work with the new dictionary format
  • Validated CLI: Ensured all CLI commands work correctly with the changes

Testing

All CLI functionality has been validated:

  • pedal grade simple_test.py submissions/correct.py --environment terminal
  • pedal sandbox submissions/correct.py
  • pedal --help
  • Package imports and resolver tests ✅

The sectional resolver maintains its existing format since it handles multiple sections differently, but the main single-result resolvers are now fully unified.

Fixes #140.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits September 2, 2025 01:43
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Copilot AI changed the title [WIP] What do Resolvers return? Unify resolver return types for consistent CLI pipeline behavior Sep 2, 2025
Copilot AI requested a review from acbart September 2, 2025 01:47
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.

What do Resolvers return?

2 participants