Documentation home

Java SDK

Use the Java SDK for JVM services and enterprise backends.

Install

The recording and Semiotic Probe release is published on GitHub at v0.3.0-dev.1. Use Java 17 or later and install from JitPack with the version below.

repositories { mavenCentral(); maven { url = uri("https://jitpack.io") } }
dependencies { implementation("com.github.haltstate-ai:sdk-java:v0.3.0-dev.1") }

Install this published release explicitly to use recording and Semiotic Probes. Existing integrations remain on the Standard contract unless enrolled for replay. Semiotic Probes use an isolated model hook, your existing tenant API key and the server-managed low-frequency schedule.

Guard shape

HaltStateConfig config = HaltStateConfig.builder(
    System.getenv("HALTSTATE_TENANT_ID"),
    System.getenv("HALTSTATE_API_KEY")
).agentId("retail-refund-agent").build();
String operatorEpoch = "11111111-2222-4333-8444-555555555555";
String destinationKey = "refund:lge_123";
String guardKey = "hsr1:" + operatorEpoch + ":" + destinationKey;

try (HaltStateClient client = new HaltStateClient(config);
     GuardContext guard = client.guard("refund.create", Map.of("amount", 126, "currency", "USD"), guardKey)) {
    guard.getPermit().validateForExecution();
    try {
        executeRefundOnce();
        guard.markSucceeded();
    } catch (RuntimeException actionError) {
        guard.checkFailed(actionError.getMessage());
        throw actionError;
    }
}

Persist guard.getPermit(), guard.getReportId(), and the exact outcome payload. If close cannot confirm a receipt, retry the public reportGuardOutcome call and retain its GuardReceipt; do not rerun the destination action.

Full operation identity

HaltStateConfig config = HaltStateConfig.builder(
    System.getenv("HALTSTATE_TENANT_ID"),
    System.getenv("HALTSTATE_API_KEY")
).agentId("retail-refund-agent").build();
String operatorEpoch = "11111111-2222-4333-8444-555555555555";
String destinationKey = "refund:" + ledgerEntryId;
String guardKey = "hsr1:" + operatorEpoch + ":" + destinationKey;

try (HaltStateClient client = new HaltStateClient(config);
     GuardContext guard = client.guard(
         "refund.create",
         Map.of("amount", 126, "currency", "USD"),
         guardKey,
         "retail-refund-agent",
         "refund/" + ledgerEntryId,
         "low"
     )) {
    guard.getPermit().validateForExecution();
    try {
        executeRefundOnce();
        guard.markSucceeded();
    } catch (RuntimeException actionError) {
        guard.checkFailed(actionError.getMessage());
        throw actionError;
    }
}

Replay-enabled SDK contract

The stable retry identity binds the exact agent, action or tool, resource, normalized parameters, risk class, and immutable policy version. With an operator-issued activation epoch, the SDK may create epoch-qualified generated keys only when the caller omitted a key; explicit keys are never changed. Approval expiry blocks a stale permit, while already_started and completed remain terminal. After the side effect, receipt validation requires the durable event ID, receipt hash, received flag, and duplicate marker; retry the same report identity without rerunning the action.

Use this contract only for an explicitly enrolled replay integration. Published release channels and version-specific features are listed above; package installation alone does not activate replay routing.

Implementation notes

Keep the HaltState call as close as possible to the side effect. The agent may plan and draft freely, but the wrapper around the actual action should be the place where authority is checked. That wrapper should send only the context required for policy evaluation: safe identifiers, normalized amounts, action names, risk flags, schedule windows, and redaction status. Raw customer payloads and secrets should stay in the business system or protected operator tooling.

Operational evidence

For each action, preserve the decision, the worker outcome, the idempotency key, safe resource references, latency, proof status, and redaction status. This evidence supports incident response and control narratives because it shows what the system did at runtime rather than only describing what the policy document intended. HaltState supports alignment work; it is not a substitute for legal advice or a compliance certification.