fix(workspace): align marker fallback (#62) - #68
Conversation
Signed-off-by: ainetx <viator@via-net.org> Co-authored-by: Constructor Studio <291158726+constructor-studio[bot]@users.noreply.github.com> Studio-Generated-By: Constructor Studio Studio-Source-Repo: https://github.com/constructorfabric/studio Constructor-Fabric: https://github.com/constructorfabric Studio-Version: skill=1.6.1 Studio-Workflows: cf-brainstorm,cf-coding-fix,cf-coding-ci,cf-git-commit
📝 WalkthroughWalkthroughThe PR makes ChangesWorkspace marker compatibility
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant WorkspaceDiscovery
participant WorkspaceInit
participant WorkspaceInfo
participant Filesystem
CLI->>WorkspaceDiscovery: Load workspace context
WorkspaceDiscovery->>Filesystem: Check canonical and legacy markers
Filesystem-->>WorkspaceDiscovery: Return marker state
WorkspaceDiscovery-->>CLI: Return WorkspaceConfig
CLI->>WorkspaceInit: Initialize with force
WorkspaceInit->>Filesystem: Write canonical marker and remove legacy fallback
Filesystem-->>WorkspaceInit: Return write or rollback result
CLI->>WorkspaceInfo: Inspect workspace
WorkspaceInfo-->>CLI: Emit fallback warning and JSON status
Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@schemas/workspace.schema.json`:
- Around line 4-5: Update the description in the workspace schema metadata to
clarify that .studio-workspace.toml is used as a legacy automatic discovery
fallback but remains supported when supplied as an explicit workspace path.
Preserve the existing canonical filename and multi-repo workspace description.
In `@skills/studio/scripts/studio/commands/workspace_init.py`:
- Around line 374-375: Update the workspace initialization hint that
interpolates rel so it uses rel.as_posix() before embedding the path in the TOML
basic string, ensuring Windows paths contain forward slashes. Add a regression
test covering Windows-style paths and verifying the rendered hint is TOML-safe.
- Around line 300-301: Update the force-write flow in
_write_standalone/_write_workspace_config to reconcile
existing_ws.is_legacy_fallback: write the canonical .cf-workspace.toml
successfully, then remove or rename .studio-workspace.toml as part of one safe
transition so discovery never sees both markers. Preserve the legacy warning,
and extend the E2E test with a workspace-info assertion confirming the
post-write workspace resolves correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9af92dd4-29ea-47b9-b6f2-4b47450fb617
📒 Files selected for processing (8)
architecture/ADR/0020-cpt-studio-adr-rebrand-and-mirror-override-v1.mdguides/MIGRATING-FROM-CYPILOT.mdschemas/workspace.schema.jsonskills/studio/scripts/studio/commands/workspace_info.pyskills/studio/scripts/studio/commands/workspace_init.pyskills/studio/scripts/studio/utils/workspace.pytests/test_cli_workspace_diag_e2e.pytests/test_workspace.py
Signed-off-by: ainetx <viator@via-net.org> Co-authored-by: Constructor Studio <291158726+constructor-studio[bot]@users.noreply.github.com> Studio-Generated-By: Constructor Studio Studio-Source-Repo: https://github.com/constructorfabric/studio Constructor-Fabric: https://github.com/constructorfabric Studio-Version: skill=1.6.1 Studio-Workflows: cf-brainstorm,cf-coding-fix,cf-coding-review,cf-coding-ci,cf-git-commit
code-ranker View diff report ↗python
🤖 Prompt for fix all with AIbaseline main @36e7861 2026-07-24 02:33 UTC · updated 2026-07-24 03:18 UTC |
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_workspace.py (1)
2812-2846: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the double-unlink-failure path.
test_write_workspace_config_rolls_back_canonical_when_legacy_cleanup_failsonly covers legacy-unlink-fails-but-rollback-succeeds. The other error branch in_replace_legacy_workspace_marker— where the canonical rollback unlink also fails, leaving both markers on disk — is untested. That's the worst-case state this whole feature is designed to prevent from going unnoticed, so it's worth a dedicated test asserting the "Rollback also failed" message and that both files still exist.♻️ Suggested additional test
def test_write_workspace_config_reports_both_failures_when_rollback_also_fails(self): with TemporaryDirectory() as tmpdir: project_root = Path(tmpdir) legacy_path = project_root / ".studio-workspace.toml" canonical_path = project_root / ".cf-workspace.toml" legacy_path.write_text('version = "1.0"\n[sources]\n', encoding="utf-8") existing_ws = WorkspaceConfig( workspace_file=legacy_path.resolve(), is_legacy_fallback=True, ) with patch.object(Path, "unlink", autospec=True, side_effect=OSError("locked")): exit_code, data = _write_workspace_config( False, None, project_root, project_root, {"version": "1.0", "sources": {}}, existing_ws, ) assert exit_code == 1 assert data["status"] == "ERROR" assert "Rollback also failed" in data["message"] assert legacy_path.is_file() assert canonical_path.is_file()🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_workspace.py` around lines 2812 - 2846, Add a test alongside test_write_workspace_config_rolls_back_canonical_when_legacy_cleanup_fails that forces both legacy cleanup and canonical rollback unlink operations to raise OSError. Call _write_workspace_config with the legacy fallback workspace, then assert an error exit/status, a message containing “Rollback also failed,” and that both legacy_path and canonical_path remain on disk.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/test_workspace.py`:
- Around line 2812-2846: Add a test alongside
test_write_workspace_config_rolls_back_canonical_when_legacy_cleanup_fails that
forces both legacy cleanup and canonical rollback unlink operations to raise
OSError. Call _write_workspace_config with the legacy fallback workspace, then
assert an error exit/status, a message containing “Rollback also failed,” and
that both legacy_path and canonical_path remain on disk.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d250fca2-b3a2-4dc8-b61a-a744edfeb0aa
📒 Files selected for processing (4)
schemas/workspace.schema.jsonskills/studio/scripts/studio/commands/workspace_init.pytests/test_cli_workspace_diag_e2e.pytests/test_workspace.py
🚧 Files skipped from review as they are similar to previous changes (1)
- schemas/workspace.schema.json



Summary by CodeRabbit
.cf-workspace.tomlworkspace marker support, while keeping.studio-workspace.tomlas a legacy discovery fallback.workspace-init/workspace-infocorrectly reflect legacy vs canonical outcomes.