Skip to content

fix: handle plain-text trust evaluation requests#1

Open
lawyered0 wants to merge 1 commit intoelizaos-plugins:1.xfrom
lawyered0:codex/fix-evaluate-trust-plain-text
Open

fix: handle plain-text trust evaluation requests#1
lawyered0 wants to merge 1 commit intoelizaos-plugins:1.xfrom
lawyered0:codex/fix-evaluate-trust-plain-text

Conversation

@lawyered0
Copy link
Copy Markdown

@lawyered0 lawyered0 commented Feb 14, 2026

Summary

  • avoid JSON parse crashes when EVALUATE_TRUST receives normal text messages
  • support both direct trust-engine services and wrapped services
  • add regression test for wrapped service resolution

Testing

  • bun test src/actions/tests/evaluateTrust.test.ts --run -t "simple trust level|wrapped trust-engine services"

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced validation of trust service availability
    • Improved handling of nested trust service configurations
    • Better input parsing and validation for trust evaluation requests
  • Tests

    • Added comprehensive test coverage for wrapped trust-engine services

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 14, 2026

Walkthrough

The pull request adds support for wrapped trust-engine services through enhanced request parsing and service retrieval logic. A new test case validates the wrapper pattern, and the handler now includes stronger validation for service availability before attempting to evaluate trust.

Changes

Cohort / File(s) Summary
Test Coverage
src/actions/__tests__/evaluateTrust.test.ts
Added test case validating wrapped trust-engine service pattern; mocks runtime.getService to return trustEngine within a wrapper object and asserts correct invocation with context data.
Service Wrapper Support & Parsing
src/actions/evaluateTrust.ts
Introduced EvaluateTrustRequest type and parseEvaluateTrustRequest() helper for structured input parsing; refactored handler to retrieve trust engine from nested trustService?.trustEngine ?? trustService pattern; strengthened validation to verify both engine presence and evaluateTrust function availability.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Wrapped with care, the trust engine shines,
Nested safely in a helper's design,
Parsing requests with validation so tight,
The trusty services now work just right! 🔐

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 'fix: handle plain-text trust evaluation requests' directly aligns with the main objective to avoid JSON parse crashes when EVALUATE_TRUST receives plain text messages.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into 1.x

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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.

Copy link
Copy Markdown

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/actions/__tests__/evaluateTrust.test.ts (2)

195-203: ⚠️ Potential issue | 🟠 Major

Test assertion will fail: error is a string, not true.

The handler (line 142) returns error: error instanceof Error ? error.message : 'Unknown error', which evaluates to the string 'Database error' here. The assertion .toBe(true) will not match.

Proposed fix
-    expect((result as any).error).toBe(true);
+    expect((result as any).error).toBe('Database error');

205-214: ⚠️ Potential issue | 🟠 Major

Same mismatch: handler returns an error string, not a boolean.

The handler (line 66) returns error: 'Entity name resolution not implemented', but the test asserts .toBe(true).

Proposed fix
-    expect((result as any).error).toBe(true);
+    expect((result as any).error).toBe('Entity name resolution not implemented');
🧹 Nitpick comments (1)
src/actions/evaluateTrust.ts (1)

40-43: validate doesn't mirror the handler's unwrap + capability check.

validate returns !!trustEngine (truthy check on the raw service), while the handler additionally unwraps .trustEngine and verifies typeof evaluateTrust === 'function'. If a wrapper object is registered that doesn't contain a valid trustEngine, validate will pass but the handler will throw.

Consider aligning the two so validate rejects early:

Suggested alignment
  validate: async (runtime: IAgentRuntime, _message: Memory) => {
-   const trustEngine = runtime.getService('trust-engine');
-   return !!trustEngine;
+   const trustService = runtime.getService('trust-engine') as any;
+   const trustEngine = trustService?.trustEngine ?? trustService;
+   return !!trustEngine && typeof trustEngine.evaluateTrust === 'function';
  },

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