Skip to content

fix(rca): require explicit user approval before applying RCA fix suggestions#317

Merged
gaurav-singh-9227 merged 2 commits into
mainfrom
fix/rca-require-explicit-fix-approval
Jun 15, 2026
Merged

fix(rca): require explicit user approval before applying RCA fix suggestions#317
gaurav-singh-9227 merged 2 commits into
mainfrom
fix/rca-require-explicit-fix-approval

Conversation

@gaurav-singh-9227

Copy link
Copy Markdown
Collaborator

What & why

When a user fetches RCA (Root Cause Analysis) for a test via fetchRCA, the returned analysis may include a suggested code fix. Today that fix is labeled "Recommended Fix", which can nudge a consuming agent to apply the change automatically.

This PR makes the suggested fix a proposal only — the assistant must present it and wait for explicit user approval before editing any files. No code change is applied automatically.

The MCP server itself never edits files; the consuming agent does. So the reliable lever is the tool's returned content (read at action time) and the tool prompt — both are updated here.

Changes

  • src/tools/rca-agent-utils/format-rca.ts
    • Relabel **Recommended Fix:****Suggested Fix (proposal only — do not apply without explicit user approval):**.
    • When any test case has a fix suggestion, append an Action required directive instructing the agent to apply code changes only after explicit user approval and to never modify files automatically. Conditional, so no noise is added when no fix is suggested.
  • src/tools/rca-agent.ts
    • Tighten the fetchRCA tool prompt to state fixes are suggestions only and require explicit user approval.
  • README.md
    • Add a Note under Automated Testing documenting that RCA fixes are proposals requiring user approval.
  • tests/tools/formatRCAData.test.ts (new)
    • Cover the proposal labeling, the approval-gate directive when a fix exists, and its absence when no fix is suggested. (The existing rcaAgent.test.ts mocks format-rca, so a dedicated unmocked test file was added.)

Testing

npm run build passes locally — lint, format, all 185 tests (3 new), and tsc all green.

🤖 Generated with Claude Code

gaurav-singh-9227 and others added 2 commits June 15, 2026 18:02
…estions

The fetchRCA tool returns a suggested fix that the consuming agent may act
on. Frame the fix as a proposal and gate it behind explicit user approval so
no code changes are applied automatically:

- format-rca.ts: relabel "Recommended Fix" as a proposal and append an
  approval-gate directive when a fix is suggested
- rca-agent.ts: tighten the fetchRCA prompt to state fixes are suggestions
  only and require explicit user approval
- README.md: document that RCA fixes are proposals requiring approval
- add tests for the approval-gate behavior

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gaurav-singh-9227 gaurav-singh-9227 merged commit 35eb4af into main Jun 15, 2026
5 checks passed
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.

2 participants