CleverCase

Shield V2

Rusakov Shield posture, response sanitization, sealed env, and CleverCase shield.yaml

Shield V2 (Rusakov Shield)

CleverCase runs under Rusakov Shield V2 — a tenant posture engine that seals secrets in memory, sanitizes API responses, detects prompt attacks, and enforces legal compliance (SOC 2, HIPAA, ABA 1.6/5.4). The canonical tenant posture lives in packages/rak-plugin-clevercase/shield.yaml and extends the platform legal vertical preset.

sanitizeApiResponse

Customer-facing routes must pass payloads through sanitizeApiResponse() from @rakontevr/shield (vendor: vendor/rakontevr/shield/src/sanitizer.ts). The sanitizer strips:

  • Internal orchestration metadata (_executionPath, _provider, _modelId)
  • Stack traces and internalTrace fields
  • Sealed key values (connection strings, bearer tokens, API keys)

CleverCase shield.yaml enables sanitizeResponses: true and defines an inline sanitizer policy with key deny-lists and regex patterns for Postgres URLs, Bearer tokens, OpenAI/Anthropic keys, and CC_MSO_* keys.

import { sanitizeApiResponse } from "@rakontevr/shield";

export async function GET() {
  const raw = await fetchUpstream();
  return NextResponse.json(sanitizeApiResponse(await raw.json()));
}

responseSanitization toggles in shield.yaml:

ToggleEffect
stripExecutionPathsRemove inference routing paths
stripProviderMetadataHide provider names
stripModelIdsHide internal model identifiers
stripInternalTracesRemove debug trace blobs
allowPublicErrorsfalse — generic errors only

Sealed environment

bootstrapSealedEnv encrypts sensitive env vars in worker memory at boot. CleverCase sealed keys:

KeyPurpose
DATABASE_URLCluster Postgres connection
REDIS_AI_URLJob queues / worker heartbeats
RAK_GATEWAY_SERVICE_KEYGateway M2M auth
RAKONTEVR_SERVICE_KEYBuilderHub proxy auth
JWT_SECRETSession signing
OPENAI_API_KEY / ANTHROPIC_API_KEYCloud inference
CC_MSO_MASTER_KEYMSO admin operations

Agents and logs must never echo sealed values. Use sealedEnvGet() server-side only; never serialize sealed keys into API responses or MCP tool output.

Posture engine

bootstrapShieldFromYaml loads tenant posture and merges with platform defaults via mergeShieldPosture. Surfaces enabled for CleverCase:

  • worker — background jobs and inference workers
  • gateway — RSP gateway completions
  • mcp — Cursor MCP tool catalog
  • sdk — @rakontevr/sdk client calls

getShieldSurfaceConfig(surface) returns per-surface sanitizer, attack detection, and agent shield policies. CleverCase shield posture name: clevercase.

Attack detection

detectPromptAttack scores inbound prompts against a corpus of injection/jailbreak templates. CleverCase thresholds:

LevelScore
critical8.0
high6.0
medium4.0

Settings: attackDetection.enabled: true, logOnly: false, learnFromBlocks: true. Blocked attacks are logged to audit tables without exposing attack text in client responses.

Agent shield

guardAgentAction enforces per-tool rate limits and a blocked-tool list. CleverCase blocks destructive agent tools:

  • drop_table, delete_case, purge_trust_account, export_all_clients

Rate limits: 10 calls per tool per minute, 100 global per minute.

CleverCase shield.yaml highlights

extends:
  - legal

compliance:
  standards: [soc2, hipaa, aba-1.6, aba-5.4]
  dataClassification: legal-privileged
  requireNimPiiScan: true
  cloudOffloadRequiresMasking: true

piiEntities:
  - case_number
  - attorney_bar_number
  - client_matter_id
  - trust_account_number

ragDefense:
  enabled: true
  stripInstructionPatterns: true
  requireUntrustedEnvelope: true

MSO content-blind (ABA 5.4)

MSO admin views return aggregates only — counts and billing rollups, never cross-firm matter narratives. RLS and tenant_sharing_grants scope conflicts-index for blind conflict matching.

Cloud offload masking

When legal text routes to external inference (allowCloudOffload: true), cloudOffloadRequiresMasking: true requires NIM PII scan/mask before offload.

Verification

CheckCommand
Shield statusclevercase shield status
Shield auditclevercase shield audit
BDD compliancepackages/rak-plugin-clevercase/src/__tests__/shield-compliance.bdd.test.ts
  • docs/RUSAKOV-SHIELD-TENANT.md
  • packages/rak-plugin-clevercase/rak-plugin.json → shield block
  • Rakontevr SDK

On this page