Skip to content

fix(mcp): stop a cleared enrollment reporting as a failed persist - #1444

Open
khaliqgant wants to merge 1 commit into
mainfrom
fix/1432-mcp-cleared-enrollment-message
Open

fix(mcp): stop a cleared enrollment reporting as a failed persist#1444
khaliqgant wants to merge 1 commit into
mainfrom
fix/1432-mcp-cleared-enrollment-message

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Aug 6, 2026

Copy link
Copy Markdown
Member

Follow-up to #1439, which merged at f8c644838 while this last review finding was still being fixed. Everything else from that PR is in main; this is the one commit that missed the merge.

The bug

#1439 made MCP set_workspace_key report a cleared fleet-node enrollment through the warning string it already used for persistence failures. Reusing one variable for two outcomes made the success case take the failure branch:

const message = persistenceWarning ? `${activeMessage} ${persistenceWarning}` : persistedMessage;

A cleared enrollment means persistWorkspaceSession succeeded. Selecting activeMessage answered "Workspace key set." — the wording that exists specifically to say the key did not persist — while the key had in fact persisted and the only thing that happened was the enrolled node being dropped.

The tool's own description, updated in the same PR, promised the opposite: that the message states whether the key was persisted.

Caught by CodeRabbit on #1439 (comment); the finding is correct and the bug was mine.

The fix

The two outcomes are tracked separately:

  • write failed → active-not-persisted wording plus the failure detail, unchanged
  • write succeeded and cleared an enrollment → persisted wording followed by the clearing notice
  • write succeeded and cleared nothing → persisted wording alone, unchanged

Test bar

reports an enrolled fleet node dropped by joining another workspace now asserts both halves, including the absence of the failure wording. Mutation-checked by restoring the conflated single-variable form:

× reports an enrolled fleet node dropped by joining another workspace
  → 3 failed | 24 passed
restored → 2 failed | 25 passed

The 2 remaining are pre-existing on main (telemetry machine-id), unrelated and present before this branch.

Gates

  • npm run typecheck — exit 0
  • npx vitest run — 1760 passed, 16 skipped, 5 failed
  • npm run format:check — clean

The 5 failures are the same pre-existing main failures documented on #1439: telemetry/client.test.ts (2), agent-relay-mcp.startup.test.ts (2), packages/cloud/src/auth.test.ts (1).

Refs #1432

🤖 Generated with Claude Code

Review in cubic

Reusing `persistenceWarning` for the cleared-enrollment message meant
`set_workspace_key` took the failure branch on success, answering with
"the workspace is active for this process" — i.e. telling the caller the
key had NOT persisted — when it had, and when the only thing that happened
was the enrolled node being dropped. The tool's own description promised
the opposite.

The two outcomes are now tracked separately: a failed write still reports
the active-not-persisted wording, and a successful write that cleared an
enrollment reports the persisted wording followed by the clearing notice.
Test asserts both halves, including that the failure wording is absent.

Refs #1432

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@cursor

cursor Bot commented Aug 6, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 825b4e66-4012-43af-aca5-044bcb7b6a49

📥 Commits

Reviewing files that changed from the base of the PR and between be073c5 and f02a010.

📒 Files selected for processing (2)
  • packages/cli/src/cli/agent-relay-mcp.startup.test.ts
  • packages/cli/src/cli/agent-relay-mcp.ts

📝 Walkthrough

Walkthrough

The set_workspace_key flow now distinguishes persistence failures from successful persistence that clears project enrollment. The startup test verifies the success wording and absence of failure wording.

Changes

Workspace persistence reporting

Layer / File(s) Summary
Persistence status and enrollment warning
packages/cli/src/cli/agent-relay-mcp.ts, packages/cli/src/cli/agent-relay-mcp.startup.test.ts
The response reports persistence errors when writes fail. Successful writes include any cleared-enrollment warning. The test verifies the successful wording.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested reviewers: willwashburn

Poem

A rabbit hops through workspace light,
Persistence now reports just right.
A cleared node warning stays in view,
Failed writes say what failed too.
The tests thump softly: “Success is true!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the bug, fix, expected outcomes, affected test, and validation results, although it does not use the template headings.
Title check ✅ Passed The title clearly and concisely identifies the MCP fix for incorrect failure reporting after cleared enrollment.
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/1432-mcp-cleared-enrollment-message

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 2 files

Re-trigger cubic

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