Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 1, 2025

Model variable and parameter names were created via eval() in the MacroModelling module namespace, causing conflicts with built-in functions (max, min, exp) and imported constants (SymPy's sqrt2).

Changes

Core isolation mechanism

  • Added ModelSymbols submodule as isolated namespace for all model symbols
  • Added eval_in_symbols() helper to evaluate expressions in isolated context

Symbol creation and access

  • create_symbols_eqs!(): Changed symbol creation from eval(:($x = SPyPyC.symbols(...))) to Core.eval(ModelSymbols, :($x = SPyPyC.symbols(...)))
  • simplify(): Isolated SymPy symbol creation and evaluation
  • transform_obc(): Isolated OBC constraint symbol handling
  • All symbol access updated: eval(:($x))eval_in_symbols(:($x))

Testing

  • Added test/test_namespace_isolation.jl to verify built-in functions remain accessible and models can use common function names as variables

Example

Before: Creating a model with variable named max would shadow Julia's max() function.

After: Model symbols are isolated:

@model M begin
    max[0] = α * y[0]  # 'max' as variable name is fine
end

max(1, 5)  # Built-in max() still works

The isolation is transparent to users - no API changes required.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • julialang-s3.julialang.org
    • Triggering command: curl --retry 3 -C - --proto =https --tlsv1.2 --ciphers TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384 --silent --show-error --fail --location REDACTED --output /tmp/tmp.dbWebAttcw/juliainstaller (dns block)
  • storage.julialang.net
    • Triggering command: julia -t auto --project=. -e using Pkg Pkg.instantiate() (dns block)
    • Triggering command: julia --project=. -e using Pkg; Pkg.instantiate() (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Create an isolated namespace where, when the model is parsed, the variable and parameter names are living inside, so there is no naming conflict with function names and constants and other objects in the package module namespace. Note that this also concerns SymPy and variable names created in the package module namespace by SymPy.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 1, 2025 22:59
Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Copilot AI changed the title [WIP] Add isolated namespace for model parsing Isolate model symbol namespace to prevent conflicts with package functions and constants Nov 1, 2025
Copilot AI requested a review from thorek1 November 1, 2025 23:07
Copilot finished work on behalf of thorek1 November 1, 2025 23:07
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 7.14286% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.11%. Comparing base (c4f536a) to head (6deea4b).

Files with missing lines Patch % Lines
src/MacroModelling.jl 7.14% 26 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (c4f536a) and HEAD (6deea4b). Click for more details.

HEAD has 4 uploads less than BASE
Flag BASE (c4f536a) HEAD (6deea4b)
5 1
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #176       +/-   ##
==========================================
- Coverage   50.52%   3.11%   -47.42%     
==========================================
  Files          18      17        -1     
  Lines       10625   10540       -85     
==========================================
- Hits         5368     328     -5040     
- Misses       5257   10212     +4955     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@thorek1 thorek1 closed this Nov 26, 2025
@thorek1 thorek1 deleted the copilot/create-isolated-namespace branch November 26, 2025 22:35
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.

3 participants