Skip to content

feat(tool_policy): diagnostics RPC and Developer Options panel#2715

Merged
sanil-23 merged 23 commits into
tinyhumansai:mainfrom
MrMrVlad:feat/2136-tool-policy-diagnostics
May 28, 2026
Merged

feat(tool_policy): diagnostics RPC and Developer Options panel#2715
sanil-23 merged 23 commits into
tinyhumansai:mainfrom
MrMrVlad:feat/2136-tool-policy-diagnostics

Conversation

@MrMrVlad
Copy link
Copy Markdown
Contributor

@MrMrVlad MrMrVlad commented May 26, 2026

Summary

  • Extend tool_registry.diagnostics with policy posture, MCP allowlist summary, MCP write-audit health, and recent policy denials (redacted).
  • Record recent tool-policy blocks in a small in-memory ring buffer when the agent harness denies a tool call.
  • Add Developer Options → Diagnostics settings panel that renders the diagnostics RPC for operators and reviewers.

Problem

When tools are hidden or policy blocks execution, operators today must reconstruct state from logs and config. Issue #2136 asks for a single diagnostics surface showing inventory, policy mode, MCP allowlists, audit health, and recent denials—without exposing secrets.

Solution

  • Core: ToolPolicyDiagnostics now composes registry counts, autonomy posture, per-server MCP allow/deny list sizes, best-effort mcp_writes row count (24h), and up to 25 recent denials from tool_registry::denials.
  • Agent loop: on policy block in turn.rs, append a truncated, redacted denial record.
  • UI: ToolPolicyDiagnosticsPanel calls tool_registry.diagnostics and sections the payload for quick review.

This is the first slice of #2136 (observability + UI). Conformance reporting (runtime contract hash, hidden raw-write tool checks, copyable support bundle) can follow in a separate PR.

Submission Checklist

  • Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
  • Diff coverage ≥ 80% — CI gate enforced by .github/workflows/coverage.yml; local diff-cover not run pre-submit
  • Coverage matrix updated — N/A: diagnostics observability only; no matrix row add/remove/rename
  • All affected feature IDs from the matrix are listed in the PR description under ## Related — N/A: no matrix feature IDs touched
  • No new external network dependencies introduced (mock backend used per Testing Strategy)
  • Manual smoke checklist updated — N/A: read-only settings diagnostics surface; no release-cut change
  • Linked issue closed via Closes #NNN in the ## Related section

Impact

  • Runtime: Desktop settings UI + core RPC; no migration.
  • Security: Diagnostics are redacted; denial reasons truncated; no secrets in RPC payload.

Related

Test plan

  • cargo test tool_registry --lib (diagnostics + denials ring buffer)
  • pnpm testToolPolicyDiagnosticsPanel.test.tsx
  • pnpm format:check, pnpm lint, pnpm compile, pnpm rust:check (pre-push hook)

AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: feat/2136-tool-policy-diagnostics
  • Commit SHA: 3c63b46c1b9c5e8a265b33376932a272d412355a

Validation Run

  • pnpm --filter openhuman-app format:check
  • pnpm typecheck / pnpm compile
  • Focused tests: cargo test tool_registry --lib, Vitest panel test
  • Rust fmt/check (if changed): pre-push pnpm rust:check
  • Tauri fmt/check (if changed): included in pnpm rust:check

Validation Blocked

  • command: N/A
  • error: N/A
  • impact: N/A

Behavior Changes

  • Intended behavior change: operators can inspect tool-policy state via RPC and settings UI; recent denials visible after blocks occur in-session.
  • User-visible effect: new Developer Options → Diagnostics entry.

Parity Contract

  • Legacy behavior preserved: existing tool_registry.list / get unchanged.
  • Guard/fallback/dispatch parity checks: diagnostics loads config with existing timeout helper.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): none known
  • Canonical PR: this PR
  • Resolution: N/A

Summary by CodeRabbit

  • New Features

    • Added a "Tool Policy Diagnostics" entry in developer settings with a diagnostics panel showing policy posture, tool inventory, MCP allowlist/write-audit summaries, recent blocked calls (trimmed), and redacted-surface metrics.
    • System now records recent tool policy denials (timestamped, redacted/truncated) for diagnostics and audit visibility.
  • Tests

    • Added tests validating panel rendering and diagnostics data display.
  • Documentation

    • Added developer-facing translation strings for the diagnostics UI.

Review Change Stack

vaddisrinivas and others added 8 commits May 23, 2026 11:44
Expand tool_registry.diagnostics with policy posture, MCP allowlist summary,
MCP write audit health, and a best-effort recent-denials buffer. Add a minimal
Developer Options UI panel and unit coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@MrMrVlad MrMrVlad requested a review from a team May 26, 2026 22:23
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a recent-denial registry and records denials on blocked tool calls; extends diagnostics types and ops to be config-driven (posture, MCP allowlists, write-audit health, recent denials); updates RPC handler/tests; adds a settings panel, i18n strings, menu entry, and a route to surface diagnostics.

Changes

Tool-Policy Diagnostics Feature

Layer / File(s) Summary
Denial recording infrastructure
src/openhuman/tool_registry/denials.rs, src/openhuman/tool_registry/mod.rs, src/openhuman/agent/harness/session/turn.rs
New in-memory capped denial registry with record/list, sensitive redaction/truncation helpers, module exposure, and integration where tool-policy blocks a tool call.
Diagnostic data shapes
src/openhuman/tool_registry/types.rs, src/openhuman/tool_registry/mod.rs
Adds ToolPolicyPosture, McpAllowlistDiagnostics, McpServerAllowlistSummary, McpWriteAuditHealth, RecentPolicyDenial and updates ToolPolicyDiagnostics to include posture, allowlists, write-audit health, and recent denials.
Diagnostics computation & RPC
src/openhuman/tool_registry/ops.rs, src/openhuman/tool_registry/schemas.rs
diagnostics_for_config computes posture from Config, aggregates MCP allowlists, queries mcp_writes for write-audit health, and includes recent denials; RPC handler loads config with timeout and tests updated to assert new fields.
Diagnostics settings panel
app/src/components/settings/panels/ToolPolicyDiagnosticsPanel.tsx, app/src/components/settings/panels/__tests__/ToolPolicyDiagnosticsPanel.test.tsx, app/src/lib/i18n/en.ts
Adds a React panel that calls tool_registry.diagnostics RPC (with loading/error/ready states), renders posture, inventory, MCP servers (truncated), write-audit summary, recent denials (truncated), i18n strings, and tests that mock the RPC.
Menu and route wiring
app/src/pages/Settings.tsx, app/src/components/settings/panels/DeveloperOptionsPanel.tsx
Registers the panel route at tool-policy-diagnostics and adds a DeveloperOptions menu entry with i18n keys and inline SVG icon linking to that route.
i18n translation chunks
app/src/lib/i18n/chunks/*, app/src/lib/i18n/en.ts
Adds devOptions.toolPolicyDiagnostics.* keys across many locale chunks and the English devOptions map to support the UI strings and summaries.
Generated tools admission
src/openhuman/tools/generated.rs
Extends generated tool definitions with provenance/risk fields, adds admission config/report types and admission checks, and tests admission outcomes and external_effect behavior.

Sequence Diagram(s):

sequenceDiagram
  participant Settings as Browser Settings Panel
  participant RPC as handle_diagnostics (server)
  participant Ops as tool_registry::ops::diagnostics_for_config
  participant Denials as denials::list
  participant DB as chunk_store (mcp_writes)
  Settings->>RPC: GET diagnostics
  RPC->>RPC: load config (timeout)
  RPC->>Ops: diagnostics_for_config(&config)
  Ops->>Denials: list(MAX_RECENT)
  Ops->>DB: SELECT COUNT(*) FROM mcp_writes (last 24h)
  Ops-->>RPC: ToolPolicyDiagnostics
  RPC-->>Settings: JSON diagnostics
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

Suggested reviewers

  • graycyrus
  • sanil-23

"I hop and log each blocked try,
trimming secrets so no keys fly.
Posture, servers, audits in view—
a tiny report for the debugging crew.
Hooray, diagnostics in a neat supply!"

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 68.75% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Out of Scope Changes check ❓ Inconclusive All changes align with #2136 scope: diagnostics RPC, denial recording, UI panel, and i18n. Generated tool admission system (generated.rs) relates to tool policy infrastructure but represents significant new functionality beyond diagnostics reporting. Clarify if generated tool admission system is required for diagnostics RPC or should be submitted as a separate feature PR.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a diagnostics RPC and Developer Options panel for tool policy.
Linked Issues check ✅ Passed Changes comprehensively address #2136: RPC reports policy state with posture/MCP allowlists/write-audit/recent denials [#2136], UI panel renders diagnostics redacted [#2136], denial recording and ring buffer implemented [#2136], tests verify conformance [#2136].

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


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 and usage tips.

@coderabbitai coderabbitai Bot added feature Net-new user-facing capability or product behavior. rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. agent Built-in agents, prompts, orchestration, and agent runtime in src/openhuman/agent/. working A PR that is being worked on by the team. labels May 26, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@app/src/components/settings/panels/__tests__/ToolPolicyDiagnosticsPanel.test.tsx`:
- Line 46: The failing assertion in ToolPolicyDiagnosticsPanel.test.tsx uses an
over-escaped regex for the literal parentheses; update the expect that calls
screen.getByText(...) so the regex escapes the parentheses only once (match the
literal "(24h)" rather than backslash characters), i.e. change the pattern used
in the getByText assertion to escape parentheses correctly for "Recent (24h):".

In `@app/src/components/settings/panels/ToolPolicyDiagnosticsPanel.tsx`:
- Around line 78-224: ToolPolicyDiagnosticsPanel renders many hard-coded user
strings (e.g., "Loading…", "Diagnostics unavailable", section headers like
"Policy posture", labels like "Autonomy:", empty states) that must be localized;
import and use useT() in the ToolPolicyDiagnosticsPanel component and replace
every literal JSX string (status messages, headings, dt/dd labels, empty-state
text, list placeholders like "<unnamed>") with t('...') calls using descriptive
keys (e.g., toolPolicy.loading, toolPolicy.unavailable,
toolPolicy.policyPosture.autonomy, toolPolicy.inventory.totalTools,
toolPolicy.mcpAllowlists.enabledLabel, toolPolicy.emptyUnnamed, etc.), then add
those same keys and English values to app/src/lib/i18n/en.ts in this PR so
translations load correctly.

In `@src/openhuman/agent/harness/session/turn.rs`:
- Around line 1331-1336: The call to
crate::openhuman::tool_registry::denials::record currently forwards the raw
reason into durable telemetry (using call.name, self.tool_policy.name(),
blocked_action, reason); replace this by redacting sensitive content before the
boundary: obtain a sanitized_reason via an existing redaction helper (or add one
e.g., redact_reason(reason) that strips PII/secrets or returns a redaction
token) and pass sanitized_reason to denials::record instead of reason, ensuring
only the pre-redacted string is persisted.

In `@src/openhuman/tool_registry/denials.rs`:
- Around line 20-21: The trimmed+truncated denial text in variable `reason` (set
via `truncate_reason(reason.trim())`) is persisted and later surfaced, so you
must redact sensitive data before storing or including it in diagnostics:
replace or wrap the stored value with a redaction step (e.g., call a
`redact_reason`/`sanitize_reason` function or inline redaction logic)
immediately after truncation and before any persistence or diagnostic creation;
apply the same change to the other occurrences referenced around lines 56–65 so
no raw/unredacted `reason` is ever written to records or logs.
- Around line 71-88: Tests are flaky because they share a global denial buffer;
make them deterministic by resetting the registry at test start: add a
clear/reset helper (e.g., reset_denials() or clear_denials()) in the denials
module and call it at the beginning of record_truncates_and_bounds and
record_ignores_empty_tool so each test starts with an empty global state; keep
using record, list and MAX_DENIALS as-is but ensure tests invoke the new reset
helper before exercising record/list so no cross-test races occur.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 91e32884-03d9-4135-9820-b7a9907aa647

📥 Commits

Reviewing files that changed from the base of the PR and between 5c035d8 and 3c63b46.

📒 Files selected for processing (10)
  • app/src/components/settings/panels/DeveloperOptionsPanel.tsx
  • app/src/components/settings/panels/ToolPolicyDiagnosticsPanel.tsx
  • app/src/components/settings/panels/__tests__/ToolPolicyDiagnosticsPanel.test.tsx
  • app/src/pages/Settings.tsx
  • src/openhuman/agent/harness/session/turn.rs
  • src/openhuman/tool_registry/denials.rs
  • src/openhuman/tool_registry/mod.rs
  • src/openhuman/tool_registry/ops.rs
  • src/openhuman/tool_registry/schemas.rs
  • src/openhuman/tool_registry/types.rs

Comment thread app/src/components/settings/panels/__tests__/ToolPolicyDiagnosticsPanel.test.tsx Outdated
Comment thread app/src/components/settings/panels/ToolPolicyDiagnosticsPanel.tsx Outdated
Comment thread src/openhuman/agent/harness/session/turn.rs Outdated
Comment thread src/openhuman/tool_registry/denials.rs Outdated
Comment thread src/openhuman/tool_registry/denials.rs
Vladimir Yastreboff and others added 2 commits May 27, 2026 08:50
Localize diagnostics panel strings, redact sensitive denial reasons before
persistence, and fix the Vitest assertion for Recent (24h) copy.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@MrMrVlad
Copy link
Copy Markdown
Contributor Author

Addressed CodeRabbit + CI feedback in 4e7a457 / follow-up:

  • Frontend test: fixed over-escaped Recent (24h) regex (root cause of Vitest + coverage failures)
  • i18n: localized all ToolPolicyDiagnosticsPanel copy via useT() + en.ts keys
  • Redaction: sensitive markers (Bearer, sk-, ghp_, PEM) redacted in denials::record before persistence
  • Tests: clear global denial buffer at start of each denials unit test for parallel determinism
  • Cleanup: removed unused RecentPolicyDenial import

Re-running CI — prior Rust core failure (memory_ingestion_status_reflects_initialized_client_snapshot) passes locally and appears unrelated/flaky.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/src/lib/i18n/en.ts`:
- Around line 516-543: The new i18n keys under devOptions.toolPolicyDiagnostics
(e.g., devOptions.toolPolicyDiagnostics.posture.autonomy, .inventory.totalTools,
.mcpAllowlists.summary, etc.) were added to app/src/lib/i18n/en.ts but not
propagated to the chunked locale files; update the matching en chunk file
(en-*.ts) and every non-English locale chunk (ar, bn, de, es, fr, hi, id, it,
ko, pt, ru, zh-CN) by adding the exact same key names and using the English
strings as placeholders so the UI won’t show missing text for chunked locales —
search for the devOptions.toolPolicyDiagnostics prefix to locate where to insert
the new keys in each chunk file.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d65c2d23-973f-4aaa-a5a0-9e4568113038

📥 Commits

Reviewing files that changed from the base of the PR and between 3c63b46 and 4e7a457.

📒 Files selected for processing (6)
  • app/src/components/settings/panels/DeveloperOptionsPanel.tsx
  • app/src/components/settings/panels/ToolPolicyDiagnosticsPanel.tsx
  • app/src/components/settings/panels/__tests__/ToolPolicyDiagnosticsPanel.test.tsx
  • app/src/lib/i18n/en.ts
  • src/openhuman/tool_registry/denials.rs
  • src/openhuman/tool_registry/ops.rs
🚧 Files skipped from review as they are similar to previous changes (4)
  • app/src/components/settings/panels/tests/ToolPolicyDiagnosticsPanel.test.tsx
  • app/src/components/settings/panels/DeveloperOptionsPanel.tsx
  • app/src/components/settings/panels/ToolPolicyDiagnosticsPanel.tsx
  • src/openhuman/tool_registry/ops.rs

Comment thread app/src/lib/i18n/en.ts
@graycyrus
Copy link
Copy Markdown
Contributor

@MrMrVlad this PR has merge conflicts with main — please rebase/resolve before review.

@oxoxDev oxoxDev assigned oxoxDev and unassigned oxoxDev May 28, 2026
@sanil-23 sanil-23 self-assigned this May 28, 2026
sanil-23
sanil-23 previously approved these changes May 28, 2026
Copy link
Copy Markdown
Contributor

@sanil-23 sanil-23 left a comment

Choose a reason for hiding this comment

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

Approving from shepherd queue (round 2). All CI green or known flakes re-running; pnpm review fix round complete. Happy to merge once required reviewers concur.

sanil-23 and others added 2 commits May 28, 2026 17:00
# Conflicts:
#	src/openhuman/agent/harness/session/turn.rs
@sanil-23
Copy link
Copy Markdown
Contributor

Hi @graycyrus — flagging this for your review when you have time. MrMrVlad's tool-policy diagnostics RPC PR is currently CONFLICTING against main because #2551 (trusted-capability-providers) landed during our review-fix push and rewrote the same tool_registry crate. I'm going to attempt to rebase + resolve on his behalf (maintainer_can_modify is on); once green I'll ping again. The author's existing inline-comment thread on turn.rs:1336 has been addressed and replied to in the d517226 push.

# Conflicts:
#	src/openhuman/tool_registry/mod.rs
#	src/openhuman/tool_registry/ops.rs
#	src/openhuman/tool_registry/schemas.rs
#	src/openhuman/tool_registry/types.rs
sanil-23
sanil-23 previously approved these changes May 28, 2026
Copy link
Copy Markdown
Contributor

@sanil-23 sanil-23 left a comment

Choose a reason for hiding this comment

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

Re-approving after merging upstream/main to resolve the tool_registry conflict (induced by #2551 trusted-capability-providers landing during the rfix push). Union strategy: kept HEAD's posture/mcp_allowlists/mcp_write_audit/recent_denials AND upstream's CapabilityProviderDiagnostics in ToolPolicyDiagnostics; kept upstream's async diagnostics() + sync diagnostics_for_config() split; HEAD's test assertions migrated into ops_test.rs. cargo check passes.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/openhuman/tool_registry/ops.rs`:
- Around line 497-498: The extracted test module is being included
unconditionally via `#[path = "ops_test.rs"] mod tests;` so test code will be
compiled into non-test builds; add the test gate by prefixing the module
declaration with `#[cfg(test)]` so it becomes `#[cfg(test)] #[path =
"ops_test.rs"] mod tests;` to ensure `ops_test.rs` is only compiled for test
targets and follows repo conventions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a3842cb4-764a-4f19-97f0-a7210e9641b4

📥 Commits

Reviewing files that changed from the base of the PR and between d517226 and a7fa47b.

📒 Files selected for processing (23)
  • app/src/components/settings/panels/DeveloperOptionsPanel.tsx
  • app/src/lib/i18n/chunks/ar-1.ts
  • app/src/lib/i18n/chunks/bn-1.ts
  • app/src/lib/i18n/chunks/de-1.ts
  • app/src/lib/i18n/chunks/en-1.ts
  • app/src/lib/i18n/chunks/es-1.ts
  • app/src/lib/i18n/chunks/fr-1.ts
  • app/src/lib/i18n/chunks/hi-1.ts
  • app/src/lib/i18n/chunks/id-1.ts
  • app/src/lib/i18n/chunks/it-1.ts
  • app/src/lib/i18n/chunks/ko-1.ts
  • app/src/lib/i18n/chunks/pl-1.ts
  • app/src/lib/i18n/chunks/pt-1.ts
  • app/src/lib/i18n/chunks/ru-1.ts
  • app/src/lib/i18n/chunks/zh-CN-1.ts
  • app/src/lib/i18n/en.ts
  • app/src/pages/Settings.tsx
  • src/openhuman/agent/harness/session/turn.rs
  • src/openhuman/tool_registry/mod.rs
  • src/openhuman/tool_registry/ops.rs
  • src/openhuman/tool_registry/ops_test.rs
  • src/openhuman/tool_registry/schemas.rs
  • src/openhuman/tool_registry/types.rs
✅ Files skipped from review due to trivial changes (10)
  • app/src/components/settings/panels/DeveloperOptionsPanel.tsx
  • app/src/lib/i18n/chunks/de-1.ts
  • app/src/lib/i18n/chunks/fr-1.ts
  • app/src/lib/i18n/chunks/ar-1.ts
  • app/src/lib/i18n/chunks/en-1.ts
  • app/src/lib/i18n/chunks/zh-CN-1.ts
  • app/src/lib/i18n/en.ts
  • app/src/lib/i18n/chunks/ko-1.ts
  • app/src/lib/i18n/chunks/it-1.ts
  • app/src/lib/i18n/chunks/id-1.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • app/src/lib/i18n/chunks/hi-1.ts
  • app/src/lib/i18n/chunks/pt-1.ts
  • src/openhuman/agent/harness/session/turn.rs
  • src/openhuman/tool_registry/types.rs
  • app/src/lib/i18n/chunks/bn-1.ts
  • app/src/lib/i18n/chunks/ru-1.ts
  • app/src/lib/i18n/chunks/pl-1.ts

Comment thread src/openhuman/tool_registry/ops.rs
Address CodeRabbit feedback on PR tinyhumansai#2715 — the extracted test module was
included unconditionally via #[path = "ops_test.rs"] mod tests; which
compiled test code into non-test builds. Add the missing #[cfg(test)]
gate to match repo conventions.

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@sanil-23 sanil-23 left a comment

Choose a reason for hiding this comment

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

Re-approving on 896cf158 — addressed CodeRabbit's single inline comment (Major / Quick win): gated the extracted ops_test.rs with #[cfg(test)] per repo convention. cargo check + cargo check --tests both clean. CodeRabbit's autofix will re-review on push.

@sanil-23
Copy link
Copy Markdown
Contributor

Posted the upstream fix for the test / Rust Core Tests + Quality failure as #2865 (one-char in rpcMethods.ts). Once it lands the same red here clears.

Copy link
Copy Markdown
Contributor

@graycyrus graycyrus left a comment

Choose a reason for hiding this comment

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

@MrMrVlad heads up — CI is failing on this PR (Rust Core Tests + Quality and Rust Core Coverage), so I'm holding off on a full approval until those are green. I did spot a couple things while skimming though:

generated.rs out-of-scope dead code (src/openhuman/tools/generated.rs) — GeneratedToolAdmissionConfig, GeneratedToolAdmissionReport, and the private is_external_effect() method are all new additions with no callers anywhere in this PR. If the crate compiles with dead_code warnings as errors, these are almost certainly causing the Rust Core Tests + Quality failure. Either gate them behind #[allow(dead_code)] with a tracking comment pointing to the follow-up PR where they'll be wired up, or move them into that follow-up PR entirely. Bundling future scaffolding into a diagnostics PR makes the diff harder to review and CI harder to debug.

mcp_write_audit_health always reports enabled: true (src/openhuman/tool_registry/ops.rs) — Both the Ok and Err arms of mcp_write_audit_health set enabled: true unconditionally. If MCP write audit can actually be disabled via config, this field is always wrong. If it can't be disabled, rename enabled to something like available or add a comment documenting the invariant.

Fix the CI failures first and I'll come back to approve.

sanil-23 added a commit to sanil-23/openhuman that referenced this pull request May 28, 2026
…table parser

PR tinyhumansai#2853 added `health_snapshot: CORE_RPC_METHODS.healthSnapshot,` to
LEGACY_METHOD_ALIASES in app/src/services/rpcMethods.ts. Prettier strips
quotes from keys that are valid JS identifiers, so the canonical TS form
is unquoted (`health_snapshot:`, not `'health_snapshot':`). But the
`frontend_legacy_aliases_match_server_alias_table` test's parser
required every key to be quoted via `quoted_value()`, which panicked:

  expected quoted value in `health_snapshot`

This blocked CI on every PR rebasing onto current main (tinyhumansai#2687 + tinyhumansai#2715
confirmed inheriting the failure).

Fix the parser, not the source file:
1. Filter `//`-comment lines from the LEGACY_METHOD_ALIASES body before
   compacting (otherwise the first quoted key picks up the inline
   comment header).
2. Accept both quoted (`'foo':`) and bare-identifier (`foo:`) keys.

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@sanil-23 sanil-23 left a comment

Choose a reason for hiding this comment

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

Re-approving after merging upstream/main (incl. #2865 parser fix that clears the inherited test/Rust Core Tests + Quality + Rust Core Coverage failures). 21 legacy_aliases tests pass locally; CR's #[cfg(test)] gate fix from earlier still in place.

@sanil-23
Copy link
Copy Markdown
Contributor

Posted #2869 with the root-cause fix: #2830's merge inadvertently reverted #2786's SessionExpired classification back to BackendUserError, so the classifies_embedding_api_invalid_token_401_as_session_expired test added by #2786 has been failing on every PR rebased onto post-#2830 main. One-line classifier fix + reconciled the stale companion test.

sanil-23
sanil-23 previously approved these changes May 28, 2026
Copy link
Copy Markdown
Contributor

@sanil-23 sanil-23 left a comment

Choose a reason for hiding this comment

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

Re-approving after merging upstream/main (incl. my #2869 fix that restores the SessionExpired classification for the embedding 401 'Invalid token' wire shape). The inherited test/Rust Core Tests + Quality + Rust Core Coverage failures clear with this merge — verified locally that the 4K5 test passes on the merged head.

… gate

The Coverage Gate (diff-cover ≥ 80%) was failing on this PR at 65.6% on
ToolPolicyDiagnosticsPanel.tsx because the existing single happy-path
test left the error branch + the populated-mcp_allowlists branch + the
mcp_write_audit.last_error branch uncovered (lines 67-68, 85, 181,
183-184, 188, 210, 221, 227-228).

Add three companion tests that exercise the remaining branches:
1. renders unavailable card when the RPC throws (catch + error render)
2. renders mcp_allowlists per-server rows when populated
3. renders mcp_write_audit last_error when present

4/4 tests pass locally. Should clear the diff-cover gate.

Co-Authored-By: Claude <noreply@anthropic.com>
sanil-23
sanil-23 previously approved these changes May 28, 2026
Copy link
Copy Markdown
Contributor

@sanil-23 sanil-23 left a comment

Choose a reason for hiding this comment

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

Re-approving on 3442402 — added 3 companion tests for ToolPolicyDiagnosticsPanel covering the previously-uncovered error/mcp_allowlists/mcp_write_audit branches. 4/4 vitest tests pass locally; diff-cover gate should clear (was 65.6%, gap was a single file at ~10 lines).

@sanil-23
Copy link
Copy Markdown
Contributor

@graycyrus update — the 2 CI failures you flagged on 18:28Z (Rust Core Tests + Quality + Rust Core Coverage) were inherited from main, not this PR's code. Root cause was #2830 (commit d578b57e) clobbering #2786's SessionExpired classification for the embedding 401 wire shape. I posted the one-line fix as #2869 (merged eac431a002 at 19:15Z) and re-merged main into this PR — both failures now clear, CI fully green on a067ebfa (29 success / 0 fail).

Also addressed CodeRabbit's earlier inline comment (added #[cfg(test)] gate on ops_test.rs) and lifted the diff-coverage gate above 80% on ToolPolicyDiagnosticsPanel.tsx (added 3 companion tests for error / mcp_allowlists / mcp_write_audit branches). Ready when you have a moment.

@sanil-23 sanil-23 merged commit 972e327 into tinyhumansai:main May 28, 2026
38 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Built-in agents, prompts, orchestration, and agent runtime in src/openhuman/agent/. feature Net-new user-facing capability or product behavior. rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. working A PR that is being worked on by the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tool-policy diagnostics and conformance reporting

6 participants