Skip to content

Conversation

@alexdewar
Copy link
Collaborator

@alexdewar alexdewar commented Jan 22, 2026

Description

I went with @Aurashk's idea of adding a find-and-replace option to the patching code. It wasn't strictly necessary but hopefully we'll find a use for it outside of this one test (otherwise I'll feel silly...).

Anyway, I've added a regression test for simple example + NPV, which was the main thing. I've unhidden the NPV option too.

Closes #1062. Closes #1090.

Type of change

  • Bug fix (non-breaking change to fix an issue)
  • New feature (non-breaking change to add functionality)
  • Refactoring (non-breaking, non-functional change to improve maintainability)
  • Optimization (non-breaking change to speed up the code)
  • Breaking change (whatever its nature)
  • Documentation (improve or add documentation)

Key checklist

  • All tests pass: $ cargo test
  • The documentation builds and looks OK: $ cargo doc
  • Update release notes for the latest release if this PR adds a new feature or fixes a bug
    present in the previous release

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

Copilot AI review requested due to automatic review settings January 22, 2026 16:41
@alexdewar alexdewar requested review from Aurashk and tsmbland January 22, 2026 16:42
@alexdewar alexdewar marked this pull request as draft January 22, 2026 16:44
@alexdewar
Copy link
Collaborator Author

Oops, it seems to be failing because of insufficient demand. Maybe hold off on reviewing for now.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a find-and-replace value option to the patching infrastructure and removes the "broken" designation from the NPV (Net Present Value) objective type. The changes enable testing NPV functionality via a new regression test using the simple example model.

Changes:

  • Added value-based find-and-replace capability to the patching system
  • Removed NPV validation warnings and "broken option" checks from agent objectives
  • Added regression test for NPV using the new patching feature

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/regression.rs Added regression test definition for simple_npv patched example
src/patch.rs Introduced Replacements enum with Values variant to support find-and-replace; refactored FilePatch to use unified replacement mechanism; added unit test for value replacement
src/input/agent/objective.rs Removed NPV-specific validation code and warnings that marked it as a broken feature
src/example/patches.rs Added simple_npv patch definition that replaces "lcox" with "npv" in agent_objectives.csv
Cargo.toml Moved map-macro from dev-dependencies to main dependencies for use in patch.rs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// Patched examples
define_regression_test_with_patches!(simple_divisible);
define_regression_test_with_patches!(simple_npv);
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The regression test for simple_npv has been added, but the corresponding test data directory (tests/data/simple_npv/) does not appear to exist. The test data needs to be generated using the regenerate_test_data.sh script and committed to the repository, similar to how tests/data/simple_divisible/ exists for the simple_divisible patch. Without this test data, the regression test will fail.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I forgot to do this... I'm impressed that Copilot clocked!

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@Aurashk Aurashk left a comment

Choose a reason for hiding this comment

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

Looks good! Just had one thought looking through this.

}
}

/// Structure to hold patches for a model csv file.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be useful here to document here how these file patches behave when you chain them together. To me it's not obvious whether you can combine addition and deletion with find and replace in an ordered way or you have to pick one.

@alexdewar alexdewar mentioned this pull request Jan 23, 2026
11 tasks
@alexdewar
Copy link
Collaborator Author

Superseded by #1094.

@alexdewar alexdewar closed this Jan 23, 2026
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.

Allow for find-and-replace with file patches Unhide NPV option and add regression test

3 participants