Skip to content

Enrol harnesses in the registry, not the package init - #743

Merged
czpython merged 1 commit into
mainfrom
fix-sandbox-import-cycle
Sep 27, 2026
Merged

czpython merged 1 commit into
mainfrom
fix-sandbox-import-cycle

Conversation

@czpython

Copy link
Copy Markdown
Owner

python -c "import druks.workspaces" and python -c "import druks.sandbox.client" failed with a circular import on a fresh interpreter.

Any import of a druks.harnesses leaf module (exceptions, artifacts, datastructures) ran druks/harnesses/__init__.py. That init imported every harness, and providers imports druks.sandbox.client. Sandbox imports those leaf modules itself, so a process that imported sandbox first reached druks.sandbox.host or druks.sandbox.client while it was only partially initialized.

harnesses/registry.py is the only reader of the enrolled Harness subclasses, so the harness imports move there. The package init is now empty. A leaf import no longer loads the harnesses.

This also fixes the standalone import of druks.chat.bridge, druks.sandbox.host, druks.sandbox.repo, and druks.sandbox.runner.

Every import of a harnesses leaf module ran the package init, which loaded
all harnesses and, through providers, druks.sandbox.client. Sandbox imports
harnesses leaf modules, so importing druks.workspaces or druks.sandbox.client
first hit a partially initialized module. The registry is the only reader of
the enrolled subclasses, so it now imports the harness modules.
@czpython
czpython merged commit 55a5d6f into main Sep 27, 2026
3 checks passed
@czpython
czpython deleted the fix-sandbox-import-cycle branch September 27, 2026 18:55
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.

1 participant