Skip to content

fix(verify): use scoped targetDir for Skills component paths#902

Open
decode2 wants to merge 2 commits into
Gentleman-Programming:mainfrom
decode2:fix/verify-workspace-scope-skills
Open

fix(verify): use scoped targetDir for Skills component paths#902
decode2 wants to merge 2 commits into
Gentleman-Programming:mainfrom
decode2:fix/verify-workspace-scope-skills

Conversation

@decode2

@decode2 decode2 commented Jun 16, 2026

Copy link
Copy Markdown

Summary

Fixes post-apply verification for \ComponentSkills\ when --scope=workspace\ is used. The verifier was checking skill paths in the global home directory instead of the workspace-scoped directory, causing 33 false failures.

Root Cause

In \componentPathsWithWorkspaceScoped\ (\internal/cli/run.go), the \ComponentSkills\ case passed \homeDir\ instead of the already-computed \ argetDir\ to \skills.SkillPathForAgent. Every other component case correctly uses \ argetDir.

The install path at line 788 already uses \ argetDir\ correctly:
\\go
targetDir := componentInjectionDirScoped(s.homeDir, s.workspaceDir, s.scope, adapter)
skills.Inject(targetDir, adapter, skillIDs)
\\

But the verify path used \homeDir:
\\go
path := skills.SkillPathForAgent(homeDir, adapter, skillID) // BUG
\\

Fix

One-line change: \homeDir\ → \ argetDir\ in the \ComponentSkills\ case.

Tests

  • Added \TestComponentPathsWorkspaceScopedSkillsUsesWorkspaceDir\ — verifies that with \ScopeWorkspace, skill paths are under the workspace dir and NOT under the home dir.
  • Updated \TestComponentPathsOpenClawSkillsSkipsSDDPhaseSkills\ — the test was passing an unused \ .TempDir()\ as workspaceDir but expecting home paths. OpenClaw always uses workspaceDir when set (per \componentInjectionDirScoped), so the test now reflects the correct behavior.

Closes #785

Summary by CodeRabbit

Bug Fixes

  • Fixed skill path resolution so workspace-scoped per-skill verification and backup target paths are derived from the provided workspace directory (rather than the home-scoped location).
  • Improved coverage with updated and new tests to confirm OpenClaw skill paths are included under the workspace scope while SDD phase skills are excluded, and that equivalent home-scoped paths are not selected when only workspace-scoped skills are present.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0424930e-c9d5-4a22-a00a-ad94dbcd5f3c

📥 Commits

Reviewing files that changed from the base of the PR and between 2e130cc and df96239.

📒 Files selected for processing (2)
  • internal/cli/run.go
  • internal/cli/run_component_paths_test.go

📝 Walkthrough

Walkthrough

In componentPathsWithWorkspaceScoped, the model.ComponentSkills branch now calls skills.SkillPathForAgent with targetDir instead of homeDir, aligning skill path resolution with the workspace/global injection scope. Two tests are updated or added to verify this scoped path behavior, and regression checks in a third test are extended to confirm workspace-scope verification uses workspace paths and excludes home paths.

Changes

ComponentSkills scope fix and tests

Layer / File(s) Summary
Fix skill path resolution to use targetDir
internal/cli/run.go
The ComponentSkills loop in componentPathsWithWorkspaceScoped now derives each skill's path from targetDir instead of homeDir, making resolved paths respect the active workspace or global scope.
Tests for workspace-scoped skill paths
internal/cli/run_component_paths_test.go
TestComponentPathsOpenClawSkillsSkipsSDDPhaseSkills is updated to assert paths exist under a workspace temp dir. New TestComponentPathsWorkspaceScopedSkillsUsesWorkspaceDir asserts that ScopeWorkspace returns skill paths under the workspace directory and excludes home-scoped equivalents. TestInstallWorkspaceScopeVerificationWithNoGlobalSkills is extended with regression checks confirming workspace-scope verification includes workspace skill paths and excludes corresponding home paths.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing the use of scoped targetDir for Skills component paths in verification.
Linked Issues check ✅ Passed The PR directly addresses issue #785 by replacing homeDir with targetDir in ComponentSkills case, fixing verification failures when using --scope=workspace.
Out of Scope Changes check ✅ Passed All changes in the PR are directly related to fixing the scope verification issue described in issue #785; no out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

The ComponentSkills case in componentPathsWithWorkspaceScoped passed
homeDir instead of the already-computed targetDir to
skills.SkillPathForAgent. When --scope=workspace, the installer writes
skills to the workspace directory but post-apply verification checked
the global home directory, causing false failures.

The install path at run.go:788 already uses targetDir correctly, so
this aligns verify with install behavior.

Also fixes TestComponentPathsOpenClawSkillsSkipsSDDPhaseSkills which
passed an unused workspace dir but expected home paths — OpenClaw
always uses workspaceDir when set, so the test now reflects that.

Closes Gentleman-Programming#785
@decode2 decode2 force-pushed the fix/verify-workspace-scope-skills branch from b0e43b3 to 2e130cc Compare June 16, 2026 05:51
@Alan-TheGentleman Alan-TheGentleman added the type:bug Bug fix label Jun 17, 2026

@Alan-TheGentleman Alan-TheGentleman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I’m requesting changes because the regression coverage stops at the internal path helper and does not assert the user-visible install --scope=workspace verification behavior from #785. Please add a focused test that runs the install path with workspace scope, no global skill files, and proves post-apply verification stays ready while checking workspace skill paths. Also run gofmt on the touched Go file before updating the PR.

…ntleman-Programming#785

Verifies that post-apply verification checks workspace paths (not home
paths) when --scope=workspace is used and no global skill files exist.

Also applies gofmt to internal/cli/run.go.

Addresses review feedback from @Alan-TheGentleman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(verify): --scope=workspace post-apply verification fails on missing GLOBAL-scope files

2 participants