Skip to content

docs: clarify that GiacContext does not yet isolate evaluations#32

Open
s-celles wants to merge 1 commit into
mainfrom
docs/clarify-context-isolation
Open

docs: clarify that GiacContext does not yet isolate evaluations#32
s-celles wants to merge 1 commit into
mainfrom
docs/clarify-context-isolation

Conversation

@s-celles
Copy link
Copy Markdown
Owner

Summary

The public signature giac_eval(expr, ctx::GiacContext) and the GiacContext type implied per-context isolation of variable bindings and computation state, but the C++ wrapper currently exposes only a process-wide singleton context. Every GiacContext value ends up funnelled into the same giac::context * (_get_cxxwrap_context()), so := bindings persist across every giac_eval call regardless of which GiacContext was passed.

This was surfaced by the MCP extension whose tool description promised "each call is independent" — a claim the implementation could not honour. Rather than masking the limitation with a restart; workaround in the MCP handler, this PR owns up to it in three layers of documentation:

  • !!! warning admonitions in the docstrings of giac_eval and GiacContext pointing to the upstream tracker.
  • A clarifying comment on _giac_eval_string explaining why its ctx_ptr parameter is ignored.
  • An updated MCP tool description telling LLM clients that bindings persist and recommending purge(name) / restart to clear state.

Upstream tracking

Filed as s-celles/libgiac-julia-wrapper#3. Once the wrapper exposes a context-aware eval entry point, _giac_eval_string can pass ctx_ptr through, real per-GiacContext isolation becomes possible, the MCP server can do clean per-call isolation, and these warning blocks can be removed.

Test plan

  • julia --project=. -e 'using Giac, ModelContextProtocol; include("test/test_mcp_ext.jl")' — 44/44 passing
  • julia --project=docs docs/make.jl — no new warnings; the !!! warning admonitions render under Documenter
  • CI green

The public signature `giac_eval(expr, ctx::GiacContext)` and the
`GiacContext` type implied per-context isolation of variable bindings
and computation state, but the C++ wrapper currently exposes only a
process-wide singleton context — `_giac_eval_string` accepts a
`ctx_ptr` and ignores it. So `:=` bindings persist across every
`giac_eval` call regardless of the `GiacContext` passed in. This was
surfaced by the MCP extension whose tool description promised "each
call is independent", a claim the implementation could not honour.

Rather than masking this with a `restart;` workaround in the MCP
handler, this commit owns up to the limitation:

- `!!! warning` blocks in the docstrings of `giac_eval` and
  `GiacContext` pointing to the upstream tracker.
- Comment on `_giac_eval_string` explaining why `ctx_ptr` is ignored.
- Updated MCP tool description telling LLM clients that bindings
  persist and recommending `purge(name)` / `restart` to clear state.

Tracked upstream as s-celles/libgiac-julia-wrapper#3. Once the wrapper
exposes a context-aware eval entry point, `_giac_eval_string` can
finally pass `ctx_ptr` through, real per-`GiacContext` isolation
becomes possible, the MCP server can do clean per-call isolation, and
these warning blocks can be removed.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.86%. Comparing base (681f1ad) to head (3dd0122).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #32      +/-   ##
==========================================
+ Coverage   79.76%   79.86%   +0.10%     
==========================================
  Files          23       23              
  Lines        2891     2891              
==========================================
+ Hits         2306     2309       +3     
+ Misses        585      582       -3     

☔ 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.

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