-
Notifications
You must be signed in to change notification settings - Fork 12
Refactoring options and imports #316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 refactors the Forge options system from struct-based to hash-based implementation, reducing overhead when adding new options. It also adds logfile support for solver solutions and fixes Windows path resolution issues for library imports.
Key changes:
- Options are now stored as hash maps instead of structs, simplifying option management and reducing boilerplate code
- Added
--logfilecommand-line flag to capture solver solutions in XML format - Library imports now use module paths instead of file paths to fix Windows compatibility issues, with
requireforms lifted to module beginning
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| forge/sigs-structs.rkt | Removed Options struct definition; replaced with DEFAULT-OPTIONS hash and updated option validation types |
| forge/sigs.rkt | Removed large state-set-option function (moved to functional variant); added --logfile CLI flag support; exported state-set-option |
| forge/sigs-functional.rkt | Implemented new hash-based state-set-option function with simplified logic using hash-set instead of struct-copy |
| forge/shared.rkt | Added logging infrastructure including setup-logfile!, log-forge-event, and remove-newlines helper function |
| forge/send-to-solver.rkt | Added maybe-log-wrap function to log solver solutions when logging is enabled |
| forge/server/modelToXML.rkt | Updated to access options from hash instead of struct |
| forge/server/forgeserver.rkt | Minor whitespace cleanup |
| forge/lang/reader.rkt | Refactored to separate and lift import statements from module body; added preprocessing step |
| forge/lang/expander.rkt | Changed library imports to use module paths (forge/library/...) instead of file paths for Windows compatibility |
| forge/tests/forge/other/open.frg | Added test cases for various Unix-style path formats including complex relative paths |
| forge/tests/forge/other/diff_dir/other_file3.frg | New test file defining sig D for path resolution testing |
| forge/tests/forge/other/diff_dir/other_file4.frg | New test file defining sig E for path resolution testing |
| forge/tests/error/*.frg | Added test files for option validation errors (bad name, type, and enum values) |
| forge/tests/error/main.rkt | Added test expectations for new option error validation |
| forge/tests/forge-functional/electrum/*.rkt | Updated to use hash-set instead of struct-copy for options |
| forge/tests/forge-core/other/target-oriented.rkt | Updated to use nested hash-set calls for setting multiple options |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| ; For debugging purposes, convert to a datum first or pretty-format will truncate. | ||
| ;(printf "Ints-coerced: ~a~n" (pretty-format (syntax->datum ints-coerced))) | ||
| ;printf "Parse-tree (converted to datum:~n ~a~n" (pretty-format (syntax->datum parse-tree))) |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon in commented-out code. Should be ;printf instead of printf to maintain consistent comment syntax.
| ;printf "Parse-tree (converted to datum:~n ~a~n" (pretty-format (syntax->datum parse-tree))) | |
| ;(printf "Parse-tree (converted to datum:~n ~a~n" (pretty-format (syntax->datum parse-tree))) |
| ; If adding new option fields, remember to update all of: | ||
| ; -- DEFAULT_OPTIONS | ||
| ; -- symbol->proc | ||
| ; -- DEFAULT_OPTIONS_HASH |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment refers to DEFAULT_OPTIONS_HASH but the actual constant is named DEFAULT-OPTIONS (defined on line 243). Update the comment to match the actual constant name.
| ; -- DEFAULT_OPTIONS_HASH | |
| ; -- DEFAULT-OPTIONS |
|
Copilot has no non-grammatical suggestions. After a 2nd look, I'm merging this. |
--logfilecommand-line flag. At the moment, this simply writes out a Racket logfile of solver solutions. This only applies to non-runqueries, sinceruns are executed only when Sterling or a Sterling mock requests.requireexpects a unix-style path even on windows. For libraries,opencommands now expand torequiresover non-string module paths like(require forge/library/util/sequences).openrequireforms are now lifted to the beginning of the Forge module. This ended up being unnecessary to fix the present issue, but the change seems better practice.