Repository navigation
fix(workflows): isolate init step process state - #5487
Open
WOLIKIMCHENG wants to merge 1 commit into
Open
WOLIKIMCHENG wants to merge 1 commit into
WOLIKIMCHENG wants to merge 1 commit into
Conversation
Run workflow init in a child process to keep concurrent project paths and output independent while preserving CLI behavior and adapter loading. Assisted-by: Codex CLI (model: gpt-6.1-sol, autonomous)
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The init subprocess retains PYTHONPATH, allowing project-local startup code to execute before bootstrap protections and bypass adapter trust checks.
4 open issues
What changed in this PR
Moves Spec Kit workflow init steps into child processes so concurrent initialization does not share the parent’s working directory or streams.
Changes:
- Uses the current Python interpreter and Spec Kit source, with an explicit working directory and captured diagnostics.
- Adds real-scaffolding regressions for concurrent execution, target paths, initialization options, and completed-step replay.
- Tests target-local adapter loading and rejection of untrusted or modified adapters.
Validation was limited to source inspection and isolated standard-library checks; project tests and before/after comparisons were not run.
| File | Description |
|---|---|
tests/workflows/test_composition_execution.py |
Tests concurrent target and stream isolation, plus resume replay. |
tests/test_workflows.py |
Adds initialization regression helpers, path and option coverage, and failure checks. |
tests/specify_cli/integrations/test_installed_adapters.py |
Tests adapter loading and trust enforcement across the child-process boundary. |
src/specify_cli/workflows/step/init/__init__.py |
Replaces in-process initialization with a pinned child-process invocation. |
Review effort: Max (adaptive)
| # click >= 8.2 captures stderr separately; older versions mix it into | ||
| # stdout and raise when ``result.stderr`` is accessed. | ||
| package_parent = str(Path(specify_cli.__file__).resolve().parent.parent) | ||
| child_env = os.environ.copy() |
| _assert_init_scaffold(tmp_path, "py") | ||
| assert (tmp_path / ".specify/presets/lean/preset.yml").is_file() | ||
|
|
||
| def test_relative_root_preserves_symlink_parent_semantics(self, tmp_path, monkeypatch): |
| monkeypatch.setattr(subprocess, "run", fail) | ||
| result = InitStep().execute({"id": "init", "project": "demo"}, StepContext(project_root=str(tmp_path))) | ||
| assert result.status == StepStatus.FAILED | ||
| assert str(tmp_path) in result.error and "fixture launch denied" in result.error |
| assert result.error and result.error != "SystemExit: 1" | ||
| assert result.output["stderr"].strip() | ||
| assert state == (os.getcwd(), sys.stdin, sys.stdout, sys.stderr, dict(os.environ)) | ||
| assert not (tmp_path / "escape").exists() |
Collaborator
|
Please address Copilot feedback |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
Prevent concurrent workflow init steps from redirecting each other's relative project paths or capturing another step's output. Invoke init in an isolated child process pinned to the current Python interpreter and Spec-Kit source, leaving the parent working directory and streams untouched.
Preserve initialization options, failure diagnostics, target-local adapter loading and completed-step replay. Regression tests reproduce wrong-target scaffolding before the fix and verify real generated projects afterward.
Testing
ruff check --no-cache src tests) passed..venv/bin/specify --help.venv/bin/python -m pytestusing focused pathsManual test results
Agent: Codex CLI | OS/Shell: Linux/Bash
/speckit.specifygenerated skill.venv/bin/specify. Template resolution, specification and quality checklist creation completed; no extension hooks were installed. A separate slash-command host invocation was not exercised.The init execution-boundary change maps to
specify initand the generated/speckit.specifyworkflow. The other changed files are regression tests. Real InitStep scaffolding was exercised by pytest.AI Disclosure
AI disclosure: AI-assisted tools were used to implement the fix and develop tests.