Skip to content

Conversation

@frontegg-david
Copy link
Contributor

@frontegg-david frontegg-david commented Dec 23, 2025

…ration

Summary by CodeRabbit

  • New Features

    • Persistence will auto-enable and inherit global Redis/Vercel KV settings when a top-level store is configured; explicit disable or explicit override remains respected.
  • Documentation

    • Updated persistence docs to explain auto-enable behavior, override rules, and legacy-store handling.
  • Tests

    • Added comprehensive tests covering auto-enable cases, overrides, legacy formats, TTL preservation, validation, and edge cases.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Walkthrough

Adds a runtime transform that auto-populates transport.persistence from top-level Redis/Vercel KV config during metadata schema parsing and adds comprehensive tests that validate behavior across multiple persistence and Redis configurations.

Changes

Cohort / File(s) Summary
Tests
libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
New test suite that isolates and validates applyAutoTransportPersistence behavior across scenarios (no global redis, global redis, Vercel KV provider, legacy redis, explicit overrides, defaultTtlMs, validation and type-guard cases). Implements a local copy of the transform and minimal schema for isolation.
Metadata transform
libs/sdk/src/common/metadata/front-mcp.metadata.ts
Adds isPersistenceObject type guard and applyAutoTransportPersistence transform; applies the transform to frontMcpMetadataSchema so transport.persistence is auto-enabled/populated from top-level redis when appropriate while preserving explicit overrides.
Docs / schema notes
libs/sdk/src/common/types/options/transport.options.ts
Documentation/comments updated to reference Redis/Vercel KV and to describe the auto-enable behavior when a top-level redis is configured. No shape or API changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Pre-merge checks and finishing touches

✅ 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 and specifically summarizes the main change: adding auto-transport persistence transformation for Redis configuration, which is the core feature across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch support-transport-persistant

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

@frontegg-david
Copy link
Contributor Author

frontegg-david commented Dec 23, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
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: 3

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3780f33 and 32f6572.

📒 Files selected for processing (3)
  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
  • libs/sdk/src/common/metadata/front-mcp.metadata.ts
  • libs/sdk/src/common/types/options/transport.options.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.ts: Use strict TypeScript mode with no any types without strong justification - use unknown instead for generic type defaults
Avoid non-null assertions (!) - use proper error handling and throw specific errors instead
Use type parameters with constraints instead of unconstrained generics
Do not mutate rawInput in flows - use state.set() for managing flow state instead

Files:

  • libs/sdk/src/common/metadata/front-mcp.metadata.ts
  • libs/sdk/src/common/types/options/transport.options.ts
  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
libs/sdk/src/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

libs/sdk/src/**/*.ts: MCP response types should use strict MCP protocol types (GetPromptResult, ReadResourceResult) instead of unknown
Use specific error classes with MCP error codes instead of generic errors
Use getCapabilities() method for dynamic capability exposure instead of hardcoding capabilities
Use changeScope property instead of scope in change events to avoid confusion with Scope class
Validate URIs per RFC 3986 at metadata level using proper validation
Validate hook flows and fail fast on invalid hook configurations with specific error messages

Files:

  • libs/sdk/src/common/metadata/front-mcp.metadata.ts
  • libs/sdk/src/common/types/options/transport.options.ts
  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
libs/**

⚙️ CodeRabbit configuration file

libs/**: Contains publishable SDK libraries. Review for API correctness, breaking changes, and consistency with docs. When public APIs change, ensure there is a matching docs/draft/docs/** update (not direct edits under docs/docs/**).

Files:

  • libs/sdk/src/common/metadata/front-mcp.metadata.ts
  • libs/sdk/src/common/types/options/transport.options.ts
  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.test.{ts,tsx}: Achieve 95%+ test coverage across all metrics (statements, branches, functions, lines)
Test all code paths including error cases and constructor validation
Include error class instanceof checks in tests to validate error handling

Files:

  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
🧠 Learnings (4)
📚 Learning: 2025-12-19T02:04:46.464Z
Learnt from: CR
Repo: agentfront/frontmcp PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-19T02:04:46.464Z
Learning: FrontMCP is a TypeScript-first schema validation framework - all types should align with MCP protocol definitions

Applied to files:

  • libs/sdk/src/common/metadata/front-mcp.metadata.ts
  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
📚 Learning: 2025-12-22T13:01:03.646Z
Learnt from: CR
Repo: agentfront/frontmcp PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-12-22T13:01:03.646Z
Learning: Applies to libs/ui/src/universal/**/*.{ts,tsx} : Export FrontMCPProvider and UniversalApp from universal app shell for platform-agnostic React configuration

Applied to files:

  • libs/sdk/src/common/metadata/front-mcp.metadata.ts
📚 Learning: 2025-12-22T13:01:16.929Z
Learnt from: CR
Repo: agentfront/frontmcp PR: 0
File: libs/uipack/CLAUDE.md:0-0
Timestamp: 2025-12-22T13:01:16.929Z
Learning: Applies to libs/uipack/src/{adapters,components,web-components}/**/*.test.ts : Test component behavior across platform configurations (OpenAI, Claude, etc.)

Applied to files:

  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
📚 Learning: 2025-12-19T02:04:46.464Z
Learnt from: CR
Repo: agentfront/frontmcp PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-19T02:04:46.464Z
Learning: Applies to **/*.test.{ts,tsx} : Test all code paths including error cases and constructor validation

Applied to files:

  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
🔇 Additional comments (3)
libs/sdk/src/common/types/options/transport.options.ts (1)

23-47: Documentation updates accurately reflect auto-enable behavior.

The updated documentation clearly describes:

  • Auto-enabling when top-level redis is configured
  • Explicit enabled: false and redis: {...} overrides
  • Redis/Vercel KV support

The documentation aligns well with the implementation in front-mcp.metadata.ts.

libs/sdk/src/common/metadata/front-mcp.metadata.ts (1)

142-177: Transform logic is correct and handles all cases properly.

The four cases are well-structured:

  1. Respect explicit enabled: false
  2. Respect explicit redis config
  3. Auto-populate redis when enabled: true without redis
  4. Auto-enable and populate when persistence is undefined

The fall-through at line 176 correctly handles edge cases like persistence: { defaultTtlMs: 5000 } where enabled defaults to false through schema parsing.

libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts (1)

3-56: Well-structured test isolation approach.

The comment on lines 3-5 clearly explains why the transform is re-implemented locally rather than imported. This is a pragmatic solution to avoid circular dependencies during testing.

The re-implemented applyAutoTransportPersistence function (lines 13-56) mirrors the production code, which allows for focused unit testing of the transform logic.

Copy link
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: 0

♻️ Duplicate comments (1)
libs/sdk/src/common/metadata/front-mcp.metadata.ts (1)

202-204: Schema transform integration is correct.

The transform is properly applied after the union schema parsing, ensuring the auto-persistence logic runs on validated data.

The documentation gap flagged in a prior review (explaining auto-enable behavior in docs/draft/docs/servers/server.mdx) remains relevant.

🧹 Nitpick comments (4)
libs/sdk/src/common/metadata/front-mcp.metadata.ts (1)

122-125: Type guard return type doesn't reflect null handling.

The function returns true for null (line 125), but the return type only includes | undefined. This means when value is null, TypeScript will incorrectly narrow it to the persistence object type.

Since null is explicitly handled, consider including it in the return type for type accuracy:

🔎 Suggested fix
 function isPersistenceObject(
   value: unknown,
-): value is { enabled?: boolean; redis?: unknown; defaultTtlMs?: number } | undefined {
+): value is { enabled?: boolean; redis?: unknown; defaultTtlMs?: number } | undefined | null {
   if (value === undefined || value === null) return true;
libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts (3)

24-75: Duplicated transform logic creates maintenance risk.

The duplicated applyAutoTransportPersistence function mirrors the source implementation, but changes to the source won't automatically update the test. Consider adding an integration test that imports and uses the actual frontMcpMetadataSchema to catch drift, even if isolated unit tests must use this duplicate.

Alternatively, add a comment warning future maintainers to keep these in sync:

// WARNING: This function must stay in sync with applyAutoTransportPersistence
// in front-mcp.metadata.ts. Update both if logic changes.

264-278: Test assertion is incomplete for the fall-through case.

The test verifies defaultTtlMs is preserved but doesn't assert what happened to enabled and redis. Add explicit assertions to verify the expected fall-through behavior:

🔎 Suggested improvement
       const result = testSchema.parse(config);

       // persistence.enabled defaults to false in schema, so transform checks Case 3 (enabled: true without redis)
       // which won't match since enabled is false by default, so it falls through
       expect(result.transport?.persistence?.defaultTtlMs).toBe(7200000);
+      // Verify enabled defaulted to false (from schema) and redis was NOT auto-populated
+      expect(result.transport?.persistence?.enabled).toBe(false);
+      expect(result.transport?.persistence?.redis).toBeUndefined();

Based on coding guidelines: "Test all code paths including error cases and constructor validation."


339-398: Good coverage of validation errors and type guard behavior.

The tests cover:

  • Schema validation errors (invalid host, port, defaultTtlMs)
  • Type guard behavior for various inputs (undefined, null, valid/invalid objects)

One remaining gap from the prior review: testing persistence: null through the full schema parse (not just the type guard). While Zod likely rejects null, adding a test would document the expected behavior:

🔎 Optional additional test
it('should handle persistence: null (schema behavior)', () => {
  const config = {
    redis: { host: 'global-redis' },
    transport: {
      persistence: null as unknown as undefined,
    },
  };
  // Verify behavior - document whether it throws or treats as undefined
  expect(() => testSchema.parse(config)).toThrow(); // or .not.toThrow() based on actual behavior
});
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 32f6572 and bc2f84a.

📒 Files selected for processing (2)
  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
  • libs/sdk/src/common/metadata/front-mcp.metadata.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.ts: Use strict TypeScript mode with no any types without strong justification - use unknown instead for generic type defaults
Avoid non-null assertions (!) - use proper error handling and throw specific errors instead
Use type parameters with constraints instead of unconstrained generics
Do not mutate rawInput in flows - use state.set() for managing flow state instead

Files:

  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
  • libs/sdk/src/common/metadata/front-mcp.metadata.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.test.{ts,tsx}: Achieve 95%+ test coverage across all metrics (statements, branches, functions, lines)
Test all code paths including error cases and constructor validation
Include error class instanceof checks in tests to validate error handling

Files:

  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
libs/sdk/src/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

libs/sdk/src/**/*.ts: MCP response types should use strict MCP protocol types (GetPromptResult, ReadResourceResult) instead of unknown
Use specific error classes with MCP error codes instead of generic errors
Use getCapabilities() method for dynamic capability exposure instead of hardcoding capabilities
Use changeScope property instead of scope in change events to avoid confusion with Scope class
Validate URIs per RFC 3986 at metadata level using proper validation
Validate hook flows and fail fast on invalid hook configurations with specific error messages

Files:

  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
  • libs/sdk/src/common/metadata/front-mcp.metadata.ts
libs/**

⚙️ CodeRabbit configuration file

libs/**: Contains publishable SDK libraries. Review for API correctness, breaking changes, and consistency with docs. When public APIs change, ensure there is a matching docs/draft/docs/** update (not direct edits under docs/docs/**).

Files:

  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
  • libs/sdk/src/common/metadata/front-mcp.metadata.ts
🧠 Learnings (9)
📚 Learning: 2025-12-19T02:04:46.464Z
Learnt from: CR
Repo: agentfront/frontmcp PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-19T02:04:46.464Z
Learning: FrontMCP is a TypeScript-first schema validation framework - all types should align with MCP protocol definitions

Applied to files:

  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
  • libs/sdk/src/common/metadata/front-mcp.metadata.ts
📚 Learning: 2025-12-22T13:01:16.929Z
Learnt from: CR
Repo: agentfront/frontmcp PR: 0
File: libs/uipack/CLAUDE.md:0-0
Timestamp: 2025-12-22T13:01:16.929Z
Learning: Applies to libs/uipack/src/{adapters,components,web-components}/**/*.test.ts : Test component behavior across platform configurations (OpenAI, Claude, etc.)

Applied to files:

  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
📚 Learning: 2025-12-19T02:04:46.464Z
Learnt from: CR
Repo: agentfront/frontmcp PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-19T02:04:46.464Z
Learning: Applies to **/*.test.{ts,tsx} : Achieve 95%+ test coverage across all metrics (statements, branches, functions, lines)

Applied to files:

  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
📚 Learning: 2025-12-22T13:01:16.929Z
Learnt from: CR
Repo: agentfront/frontmcp PR: 0
File: libs/uipack/CLAUDE.md:0-0
Timestamp: 2025-12-22T13:01:16.929Z
Learning: Applies to libs/uipack/src/**/*.test.ts : Maintain 95%+ test coverage across statements, branches, functions, and lines

Applied to files:

  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
📚 Learning: 2025-12-19T02:04:46.464Z
Learnt from: CR
Repo: agentfront/frontmcp PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-19T02:04:46.464Z
Learning: Applies to **/*.test.{ts,tsx} : Test all code paths including error cases and constructor validation

Applied to files:

  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
📚 Learning: 2025-12-22T13:01:03.646Z
Learnt from: CR
Repo: agentfront/frontmcp PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-12-22T13:01:03.646Z
Learning: Applies to libs/ui/src/**/*.test.{ts,tsx} : Use React Testing Library for component tests with 95%+ coverage across statements, branches, functions, and lines

Applied to files:

  • libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts
📚 Learning: 2025-12-19T02:04:46.464Z
Learnt from: CR
Repo: agentfront/frontmcp PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-19T02:04:46.464Z
Learning: Applies to libs/sdk/src/**/*.ts : MCP response types should use strict MCP protocol types (GetPromptResult, ReadResourceResult) instead of `unknown`

Applied to files:

  • libs/sdk/src/common/metadata/front-mcp.metadata.ts
📚 Learning: 2025-12-19T02:04:46.464Z
Learnt from: CR
Repo: agentfront/frontmcp PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-19T02:04:46.464Z
Learning: Applies to **/*.ts : Avoid non-null assertions (`!`) - use proper error handling and throw specific errors instead

Applied to files:

  • libs/sdk/src/common/metadata/front-mcp.metadata.ts
📚 Learning: 2025-12-22T13:01:03.646Z
Learnt from: CR
Repo: agentfront/frontmcp PR: 0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-12-22T13:01:03.646Z
Learning: Applies to libs/ui/src/universal/**/*.{ts,tsx} : Export FrontMCPProvider and UniversalApp from universal app shell for platform-agnostic React configuration

Applied to files:

  • libs/sdk/src/common/metadata/front-mcp.metadata.ts
🧬 Code graph analysis (1)
libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts (2)
libs/sdk/src/common/types/options/redis.options.ts (1)
  • redisOptionsSchema (171-171)
libs/sdk/src/common/types/options/transport.options.ts (1)
  • transportOptionsSchema (65-156)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Lint & Format Checks
  • GitHub Check: Build Libraries
🔇 Additional comments (2)
libs/sdk/src/common/metadata/front-mcp.metadata.ts (1)

144-200: Transform logic is well-structured and addresses prior review concerns.

The implementation correctly handles all documented cases:

  • Early exit when no global redis
  • Runtime type guard validation before proceeding
  • Respects explicit enabled: false
  • Respects explicit persistence redis config
  • Auto-populates global redis when enabled: true but no redis specified
  • Auto-enables when persistence is completely undefined

The runtime type guard (isPersistenceObject) addresses the prior concern about unsafe type assertions.

libs/sdk/src/common/metadata/__tests__/front-mcp.metadata.test.ts (1)

77-83: Test schema setup is well-designed.

Using the actual redisOptionsSchema and transportOptionsSchema while isolating the transform logic provides good coverage of real-world schema behavior without the circular dependency issues.

@frontegg-david frontegg-david merged commit 8bb97ee into main Dec 23, 2025
21 checks passed
@frontegg-david frontegg-david deleted the support-transport-persistant branch December 23, 2025 05:48
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