Skip to content

🪲 BUG-#21: Fix workspace jail global mutable state - #33

Merged
FernandoCelmer merged 3 commits into
masterfrom
feature/21
Aug 15, 2026
Merged

🪲 BUG-#21: Fix workspace jail global mutable state#33
FernandoCelmer merged 3 commits into
masterfrom
feature/21

Conversation

@FernandoCelmer

@FernandoCelmer FernandoCelmer commented Aug 15, 2026

Copy link
Copy Markdown
Member

Description

Eliminates global mutable workspace jail state (issue #21). Replaces the module-level _enabled flag and set_workspace_enabled() with per-instance workspace: bool constructor arguments on every filesystem/search tool. Introduces build_tools(workspace) factory in tools/__init__.py so each Config instance gets its own correctly-scoped tool set. Module-level DEFAULT_TOOLS/READ_ONLY_TOOLS are kept for backward compatibility via lazy __getattr__.

Motivation and Context

Closes #21. Two Config instances with different workspace= settings (or tests running in sequence) would race — whichever initialized last silently won for every tool in the process.

Types of changes

  • Bug fix
  • New feature
  • Documentation

Checklist

  • Self-review done
  • Tests added
  • CHANGELOG updated
  • Docs updated

@FernandoCelmer FernandoCelmer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The global mutable state elimination is sound. Removing _enabled/set_workspace_enabled and replacing them with per-instance workspace flags threads correctly through Config, build_tools, and every tool class. Backward-compat module-level DEFAULT_TOOLS/READ_ONLY_TOOLS via __getattr__ is a clean bridge. One issue found below.

Comment thread pycodeloop/core/config.py
@FernandoCelmer FernandoCelmer added the bug Something isn't working label Aug 15, 2026
Config.__init__ called build_tools(workspace) unconditionally to get
read_only_tools for DelegateTool, even when a caller passed a custom
tools list and delegation was off — instantiating every built-in
tool just to discard the result. Now build_tools() for the
read-only subset only runs when delegation=True actually needs it.
@FernandoCelmer
FernandoCelmer merged commit f8f0387 into master Aug 15, 2026
8 checks passed
@FernandoCelmer
FernandoCelmer deleted the feature/21 branch August 15, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

workspace jail uses a global mutable flag — concurrent CodeLoop instances or tests interfere with each other

1 participant