Skip to content

Conversation

@tnelson
Copy link
Owner

@tnelson tnelson commented Dec 9, 2025

  • Refactoring of the options system to reduce the overhead of adding new options. A set of options is no longer a struct, but a hash.
    • Improved testing for bad option values.
  • Adding a --logfile command-line flag. At the moment, this simply writes out a Racket logfile of solver solutions. This only applies to non-run queries, since runs are executed only when Sterling or a Sterling mock requests.
  • Resolving a Windows issue, where the previous refactor of the sequence library failed because Racket's require expects a unix-style path even on windows. For libraries, open commands now expand to requires over non-string module paths like (require forge/library/util/sequences).
    • Some additional testing for path resolution in open
    • The expanded require forms 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.

Copy link

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 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 --logfile command-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 require forms 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)))
Copy link

Copilot AI Dec 9, 2025

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.

Suggested change
;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)))

Copilot uses AI. Check for mistakes.
; If adding new option fields, remember to update all of:
; -- DEFAULT_OPTIONS
; -- symbol->proc
; -- DEFAULT_OPTIONS_HASH
Copy link

Copilot AI Dec 9, 2025

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.

Suggested change
; -- DEFAULT_OPTIONS_HASH
; -- DEFAULT-OPTIONS

Copilot uses AI. Check for mistakes.
@tnelson
Copy link
Owner Author

tnelson commented Dec 13, 2025

Copilot has no non-grammatical suggestions. After a 2nd look, I'm merging this.

@tnelson tnelson merged commit 4a1ac94 into dev Dec 13, 2025
7 checks passed
@tnelson tnelson deleted the feat_refactor_options branch December 13, 2025 16:12
@tnelson tnelson restored the feat_refactor_options branch December 13, 2025 16:12
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