This document outlines the plan to refactor the pgeon codebase to improve modularity, type safety, and test coverage.
- Transition to
uvfor dependency management.- Update
pyproject.tomlforuvcompatibility. - Generate
uv.lockfile.
- Update
- Ensure all existing tests pass before refactoring.
- Deprecate
PolicyGraph(src/pgeon/policy_graph.py).- Merge functionality from
PolicyGraphintoPolicyApproximatorFromBasicObservation. - Refactor
PolicyGraphusers to usePolicyApproximatorFromBasicObservation. - Remove
src/pgeon/policy_graph.py.
- Merge functionality from
- Deprecate
IntentionIntrospector(src/pgeon/intention_introspector.py).- Move intention finding logic into
IntentionAwarePolicyGraphor a new dedicated class that uses the new abstractions. - Remove
src/pgeon/intention_introspector.py.
- Move intention finding logic into
- Refactor
PolicyApproximatorandPolicyRepresentation.- Ensure
PolicyApproximatorFromBasicObservationcorrectly and consistently uses aPolicyRepresentationinstance. - Remove redundant methods between the old
PolicyGraphand the new approximators.
- Ensure
- Refactor
ipg_xai.pyfor better integration.- Update
IPG_XAI_analyserto usePolicyApproximatorandPolicyRepresentationinstead ofPolicyGraph. - Ensure type consistency with the new abstractions.
- Update
- Merge
IPG_XAI_analyserintoIntentionAwarePolicyApproximator.- Move
answer_what,answer_how, andanswer_whymethods fromIPG_XAI_analysertoIntentionAwarePolicyApproximator. - Delete
src/pgeon/ipg_xai.py. - Update
test/pgeon/test_ipg_xai.pyto reflect the changes.
- Move
- Update tests to reflect refactoring.
- Remove or update tests for deprecated files (
test_policy_graph.py,test_intention_introspector.py).
- Remove or update tests for deprecated files (
- Enhance tests for
test_policy_approximator.pyandtest_policy_representation.py. - Add new tests to improve coverage.
- Write unit tests for new or modified functionality.
- Implement end-to-end tests using the
cartpoleenvironment.
- Refactor and restructure
test_intention_aware_policy_graph.py - Add granular tests for
IntentionAwarePolicyApproximatormethods - Enhance existing
answer_*tests for more complex scenarios
- Code cleanup and final review.
- Merge the
refactor/codebase-cleanupbranch intomain.