Skip to content

fix(workspace): align marker fallback (#62) - #68

Merged
ainetx merged 2 commits into
mainfrom
fix-issue-62
Jul 24, 2026
Merged

fix(workspace): align marker fallback (#62)#68
ainetx merged 2 commits into
mainfrom
fix-issue-62

Conversation

@ainetx

@ainetx ainetx commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added canonical .cf-workspace.toml workspace marker support, while keeping .studio-workspace.toml as a legacy discovery fallback.
    • Added stderr warnings when the legacy marker is auto-detected, with guidance to migrate.
  • Documentation
    • Updated migration and workspace documentation to reflect canonical vs legacy marker behavior.
  • Bug Fixes
    • Improved marker discovery precedence and handling, including clearer error behavior when both markers are present.
    • Ensured workspace-init/workspace-info correctly reflect legacy vs canonical outcomes.

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
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR makes .cf-workspace.toml the canonical workspace marker, preserves .studio-workspace.toml for legacy discovery, rejects conflicting automatic markers, emits CLI fallback warnings, and updates migration documentation, schema metadata, and tests.

Changes

Workspace marker compatibility

Layer / File(s) Summary
Marker discovery and state tracking
skills/studio/scripts/studio/utils/workspace.py, tests/test_workspace.py, schemas/workspace.schema.json
Workspace loading prefers .cf-workspace.toml, records legacy fallback usage, rejects both automatic markers, and validates explicit legacy configuration.
CLI fallback warnings and marker replacement
skills/studio/scripts/studio/commands/workspace_*.py, tests/test_cli_workspace_diag_e2e.py, tests/test_workspace.py
CLI commands warn on legacy fallback discovery; forced initialization can replace automatic legacy markers, preserve custom markers, and roll back on cleanup failure while retaining JSON results and updated path hints.
Canonical marker documentation
architecture/ADR/0020-cpt-studio-adr-rebrand-and-mirror-override-v1.md, guides/MIGRATING-FROM-CYPILOT.md
ADR and migration guidance identify .cf-workspace.toml as canonical and .studio-workspace.toml as a legacy fallback.

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
Loading

Possibly related issues

  • Issue 62: Standardizes .cf-workspace.toml as canonical and documents .studio-workspace.toml as a legacy fallback across runtime behavior and documentation.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main change: aligning workspace marker fallback behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-issue-62

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between c824047 and 1ef9c28.

📒 Files selected for processing (8)
  • architecture/ADR/0020-cpt-studio-adr-rebrand-and-mirror-override-v1.md
  • guides/MIGRATING-FROM-CYPILOT.md
  • schemas/workspace.schema.json
  • skills/studio/scripts/studio/commands/workspace_info.py
  • skills/studio/scripts/studio/commands/workspace_init.py
  • skills/studio/scripts/studio/utils/workspace.py
  • tests/test_cli_workspace_diag_e2e.py
  • tests/test_workspace.py

Comment thread schemas/workspace.schema.json Outdated
Comment thread skills/studio/scripts/studio/commands/workspace_init.py
Comment thread skills/studio/scripts/studio/commands/workspace_init.py Outdated
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-app

Copy link
Copy Markdown
Contributor

code-ranker View diff report ↗

python
Metric Baseline Current Δ
sum always
Edges 275 277 +2
Complexity
cognitive — Cognitive complexity 125 125 $\color{#c0392b}{+0.196}$
cyclomatic — Cyclomatic complexity 125 125 $\color{#c0392b}{+0.2}$
Coupling
fan_in — Incoming dependencies 3.6 3.6 +0.026
fan_out — Outgoing dependencies 4.2 4.3 +0.031
hk — God-object risk 1.8M 1.8M $\color{#c0392b}{+824}$
Halstead
bugs — Estimated bugs 3.5 3.5 $\color{#c0392b}{+0.004}$
effort — Implementation effort 2.2M 2.2M $\color{#c0392b}{+1886}$
length — Total tokens 2055 2058 $\color{#c0392b}{+3}$
time — Coding time (s) 119.9K 120K $\color{#c0392b}{+105}$
vocabulary — Distinct symbols 259 259 $\color{#c0392b}{+0.444}$
volume — Code volume 18.9K 18.9K $\color{#c0392b}{+28}$
Lines of Code
blank — Blank lines 69.6 69.7 +0.132
cloc — Comment lines 102 102 +0.057
sloc — Source lines 445 446 +0.868
Maintainability
mi — Maintainability index 46.9 47.5 $\color{#2a7a30}{+0.62}$
🤖 Prompt for fix all with AI
Run `code-ranker check --top 1` and follow instructions to fix error. Loop until no errors left.

baseline main @36e7861 2026-07-24 02:33 UTC · updated 2026-07-24 03:18 UTC

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/test_workspace.py (1)

2812-2846: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the double-unlink-failure path.

test_write_workspace_config_rolls_back_canonical_when_legacy_cleanup_fails only 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1ef9c28 and 01fbe45.

📒 Files selected for processing (4)
  • schemas/workspace.schema.json
  • skills/studio/scripts/studio/commands/workspace_init.py
  • tests/test_cli_workspace_diag_e2e.py
  • tests/test_workspace.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • schemas/workspace.schema.json

@ainetx
ainetx merged commit d311018 into main Jul 24, 2026
23 checks passed
@ainetx
ainetx deleted the fix-issue-62 branch July 24, 2026 03:37
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