Skip to content

About

Universal cross platform development

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

universal-sdk

Universal cross platform development SDK with optional legal-assistance interfaces.

Core features

  • Cross-platform initialization and platform detection (Windows, Linux, Android)
  • System information and command execution via platform-specific implementations
  • Extensible legal-assistant module interfaces for:
    • LLM advice generation
    • Legal citation retrieval
    • Inmate data access connectors
    • Policy-based escalation and audit logging
  • Bundled stub providers for local development and testing
  • Optional persistent audit log (FileAuditWriter)

Legal-assistant guardrails

  • Configurable jurisdiction and case-type coverage
  • Consent and role-based access checks
  • INMATE role enforcement: an inmate requester may only query their own records
  • Confidence-threshold enforcement
  • Mandatory disclaimers and human-escalation paths
  • In-memory audit trail + optional external audit writer for traceability

Building

Prerequisites

  • CMake ≥ 3.10
  • C++17 compiler (GCC, Clang, or MSVC)
  • (optional) Google Test for running the test suite

Quick build

bash build.sh

Options:

Flag Description
-d / --debug Build in Debug mode (default: Release)
-b DIR Set the build directory (default: build)
-c Clean the build directory first
-i Install after building

Manual CMake build

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel

Running tests

Install Google Test first (Ubuntu):

sudo apt-get install -y libgtest-dev
cd /usr/src/googletest && sudo cmake . && sudo cmake --build . --target install

Then build and test:

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
ctest --test-dir build --output-on-failure

Quickstart

1. Include the headers

#include "universal_sdk.h"
#include "stub_providers.h"    // EchoLLMProvider, InMemoryRetrievalProvider, etc.
#include "file_audit_writer.h" // optional persistent audit log

2. Wire up providers

using namespace UniversalSDK;

// Inmate data store
auto connector = std::make_shared<InMemoryInmateDataConnector>();
connector->AddInmate("I-001", "Pending appeal filed 2026-03.");
connector->GrantAccess("I-001", AccessRole::LEGAL_ADVOCATE);

// LLM and retrieval (replace with real implementations for production)
auto llm       = std::make_shared<EchoLLMProvider>(/*confidence=*/0.9);
auto retrieval = std::make_shared<InMemoryRetrievalProvider>(
    std::vector<Citation>{{"CA Penal Code § 1237", "Grounds for appeal", "PC-1237"}});

// Coverage policy
LegalAssistantConfig config;
config.allowed_jurisdictions = {"CA"};
config.allowed_case_types    = {"appeal"};

3. Attach an audit writer (optional)

auto writer = std::make_shared<FileAuditWriter>("/var/log/legal_audit.ndjson");

4. Create the assistant and query

LegalAssistant assistant(
    llm, retrieval, connector,
    std::make_shared<DefaultPolicyEngine>(),
    config,
    writer);  // omit writer to use in-memory audit trail only

LegalQueryContext ctx;
ctx.inmate_id       = "I-001";
ctx.jurisdiction    = "CA";
ctx.case_type       = "appeal";
ctx.question        = "What grounds support a criminal appeal?";
ctx.role            = AccessRole::LEGAL_ADVOCATE;
ctx.consent_granted = true;

LegalAdviceResponse resp = assistant.Advise(ctx);
if (!resp.escalated) {
    std::cout << resp.summary << "\n";
}

Full example

See examples/legal_assistant_sample.cpp for a complete runnable demonstration.

Build and run the sample:

cmake -B build && cmake --build build --target legal_assistant_sample
./build/legal_assistant_sample

Android APK

The android/ directory contains a full Android application that wraps the SDK via JNI/NDK, providing an on-device UI for inmate legal queries.

Prerequisites

  • Android Studio Hedgehog (2023.1) or newer, or the Android command-line tools
  • Android NDK r27+ and CMake 3.22+ (installed via SDK Manager)
  • JDK 17+

Build from Android Studio

  1. Open android/ as a project in Android Studio.
  2. Let Gradle sync and download dependencies.
  3. Run Build → Build APK(s) (or press the ▶ run button to deploy to a device/emulator).

The debug APK is written to android/app/build/outputs/apk/debug/app-debug.apk.

Build from the command line

cd android
chmod +x gradlew
./gradlew assembleDebug

The debug-signed release APK (for local testing only):

./gradlew assembleRelease

Architecture

Layer Files
Android UI (Java) android/app/src/main/java/…/MainActivity.java
JNI wrapper (Java) …/LegalAssistantJNI.java, …/LegalAdviceResult.java
JNI bridge (C++) android/app/src/main/cpp/jni_bridge.cpp
NDK build android/app/src/main/cpp/CMakeLists.txt

The native layer compiles the same C++ SDK sources used on Linux/Windows (via android_impl.cpp) and exposes two JNI functions:

JNI method Description
queryLegalAdvice(…) Submit a legal query; returns a JSON-encoded LegalAdviceResult
isSDKAvailable() Confirms the native library loaded correctly
Interface Purpose
LLMProvider Generate advice text and estimate confidence
RetrievalProvider Return Citation objects for a jurisdiction/case-type/question
InmateDataConnector Gate access and supply case summaries
PolicyEngine Final allow/deny/escalate decision
AuditWriter Receive AuditEvent records for external persistence

Stub implementations (EchoLLMProvider, InMemoryRetrievalProvider, InMemoryInmateDataConnector) are included in include/stub_providers.h and src/stub_providers.cpp for testing and local development.

About

Universal cross platform development

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages