Repository navigation
Commit 8289534
committed
test(mcp): pin the fallback workspace root for both the settings path and confineTo
PR 1913's head review 5843751481 lists a failed pre-merge check whose Regression Evidence item reads:
"Add an MCP call-site test with provider `cwd` unavailable. Mock `getWorkspacePath()` to return a
distinct path and assert that the project write uses it for both the settings path and `confineTo`.
Retain the explicit-`cwd` and global-write tests." The four rows already in
src/services/mcp/__tests__/McpHub.spec.ts under "project-scoped write confinement at every call site"
all install mockProvider.cwd, so the fallback branch at McpHub.ts:2080 was never taken at a call site and
getWorkspacePath was never mocked in this file. This adds the missing row and keeps the four existing
rows untouched.
The new row installs an absent cwd, lets the mocked getWorkspacePath return /fallback/workspace, and
asserts both halves: the project settings path is /fallback/workspace/.roo/mcp.json and the confinement
root handed to safeWriteJson is /fallback/workspace. The point is that one root serves both purposes, so
a project write taken without a provider cwd is confined to the directory it actually writes into.
Kill evidence, all in wt-r160-1913 at node v22.23.4 over this spec file (94 tests with the new row):
- replacing the fallback at McpHub.ts:2080 with a different directory gave 1 failed, 93 passed: only the
new row failed, so it is what pins the settings-path half.
- giving project writes a different defined confinement root at McpHub.ts:2142 gave 2 failed, 92 passed:
the new row and the existing explicit-cwd row, so the confinement half is held from two sides.
- dropping the fallback in favour of the provider cwd alone at line 2142 gave 2 failed, 92 passed, the new
row and the global-write row that expects an unconstrained confineTo.
- a mutant that changes only getProjectMcpPath's default parameter at line 634 survived this row
(94 passed), because these call sites pass the root explicitly, so the row does not claim the default
parameter is exercised; the row covers the shared write root at 2080 and its use at 2142.
- unmutated: exit 0, 94 passed of 94 in this file.
eslint --prune-suppressions --max-warnings=0 on services/mcp/__tests__/McpHub.spec.ts exits 0 with no
output, and the file has no entry in src/eslint-suppressions.json, so its count is 0 before and 0 after.
This commit stages only that one path; a pre-existing modification of src/eslint-suppressions.json left
behind in this worktree by an earlier prune run (33,294 B against 30,910 B committed) is neither staged
nor reverted here. No --no-verify, no HUSKY=0, no git add -A, no changeset, no CHANGELOG, no label change.1 parent 2960636 commit 8289534
1 file changed
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
159 | 168 | | |
160 | 169 | | |
161 | 170 | | |
| |||
1292 | 1301 | | |
1293 | 1302 | | |
1294 | 1303 | | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
1295 | 1322 | | |
1296 | 1323 | | |
1297 | 1324 | | |
| |||
0 commit comments