Skip to content

fix(policy): prioritize trusted PostHog command risk - #146

Merged
mohanagy merged 1 commit into
developmentfrom
fix/142-posthog-risk-precedence
Jul 21, 2026
Merged

fix(policy): prioritize trusted PostHog command risk#146
mohanagy merged 1 commit into
developmentfrom
fix/142-posthog-risk-precedence

Conversation

@mohanagy

@mohanagy mohanagy commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Fixes #142

Why

A trusted static readOnlyHint was evaluated before Miftah's origin-pinned PostHog command adapter. A destructive PostHog command could therefore be classified as read.

Change

Evaluate the internal PostHog command metadata before trusted upstream annotations, while keeping local overrides highest priority.

TDD evidence

  • Added the regression with both readOnlyHint: true and call dashboard-delete {}.
  • Before the fix it failed as read / trusted-upstream-annotation.
  • After the fix it returns destructive / trusted-command-adapter.

Validation

  • npm test -- tests/risk-classifier.test.ts
  • npm test -- tests/mcp-wrapper.test.ts
  • npm run lint
  • npm run typecheck

Summary by CodeRabbit

  • Bug Fixes

    • Improved tool risk classification so trusted command evidence takes precedence over conflicting static annotations.
    • Destructive commands are now identified with the appropriate high-confidence classification.
  • Tests

    • Added coverage to verify correct risk classification when trusted command data conflicts with read-only annotations.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Walkthrough

classifyToolRisk now prioritizes trusted PostHog command metadata over static annotations, with regression coverage for destructive command classification and its source and confidence.

Changes

Risk classification

Layer / File(s) Summary
Command precedence and regression coverage
src/policy/risk-classifier.ts, tests/risk-classifier.test.ts
Trusted PostHog commands are classified before trusted static annotations; the test verifies a destructive result with trusted-command-adapter as the source and high confidence.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

A rabbit found a command in flight,
And ranked its danger true and right.
Static hints now wait their turn,
While trusted commands clearly burn.
“Hop!” says the test, “the risks are bright!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed It clearly summarizes the main change: prioritizing trusted PostHog command risk over other policy signals.
Description check ✅ Passed It covers the motivation, implementation, TDD evidence, and validation commands, though it does not follow the template exactly.
Linked Issues check ✅ Passed The code and regression test match #142 by giving PostHog command metadata precedence over static read-only hints.
Out of Scope Changes check ✅ Passed The diff stays focused on classifier precedence and one regression test, with no unrelated changes evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/142-posthog-risk-precedence

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

@mohanagy
mohanagy force-pushed the fix/142-posthog-risk-precedence branch from 9c976a2 to e8d8557 Compare July 21, 2026 08:21
@mohanagy

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mohanagy

Copy link
Copy Markdown
Owner Author

The Windows Node 24 failure is not in this policy change: the completed log shows the pre-existing cold-provider marker test timing out. It is tracked in #148 and addressed by the already-open #147 / #144 readiness-barrier PR. I will rebase and revalidate this PR after that fix is integrated; no timeout increase or unrelated change will be made here.

@mohanagy

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@mohanagy
mohanagy merged commit d8a78a1 into development Jul 21, 2026
12 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.

bug: give PostHog command metadata precedence over static read-only hints

1 participant