Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to the AxonFlow Java SDK will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [9.5.0] - 2026-10-21: Decision API approval retry fields

### Added

- Decision API payment approval wire fields: exact `target.server`, request `approval_id`, and response `pending_approval` and consumed `approval_id`. A hold is never an allow verdict; retry only after human approval and forward the payment only on an allow verdict for the spent approval.

## [9.4.0] - 2026-09-14: decision provenance, the PEP capability handshake, typed policy authoring, and the simulation family deprecated

The first Java SDK release carrying these entries sends the PEP capability handshake, which a
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.getaxonflow</groupId>
<artifactId>axonflow-sdk</artifactId>
<version>9.4.0</version>
<version>9.5.0</version>
<packaging>jar</packaging>

<name>AxonFlow Java SDK</name>
Expand Down
24 changes: 22 additions & 2 deletions src/main/java/com/getaxonflow/sdk/types/DecideRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public final class DecideRequest {
@JsonProperty("context")
private final Map<String, Object> context;

@JsonProperty("approval_id")
private final String approvalId;

private DecideRequest(Builder b) {
this.stage = b.stage;
this.query = b.query;
Expand All @@ -46,6 +49,7 @@ private DecideRequest(Builder b) {
this.userToken = (b.userToken == null || b.userToken.isEmpty()) ? null : b.userToken;
// Omit an empty context map per the wire contract (omit if empty).
this.context = (b.context == null || b.context.isEmpty()) ? null : b.context;
this.approvalId = (b.approvalId == null || b.approvalId.isEmpty()) ? null : b.approvalId;
}

/**
Expand Down Expand Up @@ -89,6 +93,11 @@ public Map<String, Object> getContext() {
return context;
}

/** Returns the approved hold this exact retry spends, or null. */
public String getApprovalId() {
return approvalId;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -99,12 +108,13 @@ public boolean equals(Object o) {
&& Objects.equals(callerIdentity, that.callerIdentity)
&& Objects.equals(target, that.target)
&& Objects.equals(userToken, that.userToken)
&& Objects.equals(context, that.context);
&& Objects.equals(context, that.context)
&& Objects.equals(approvalId, that.approvalId);
}

@Override
public int hashCode() {
return Objects.hash(stage, query, callerIdentity, target, userToken, context);
return Objects.hash(stage, query, callerIdentity, target, userToken, context, approvalId);
}

@Override
Expand All @@ -125,6 +135,9 @@ public String toString() {
+ '\''
+ ", context="
+ context
+ ", approvalId='"
+ (approvalId != null ? "<redacted>" : null)
+ '\''
+ '}';
}

Expand All @@ -136,6 +149,7 @@ public static final class Builder {
private DecisionTarget target;
private String userToken;
private Map<String, Object> context;
private String approvalId;

private Builder(String stage, String query) {
this.stage = stage;
Expand Down Expand Up @@ -186,6 +200,12 @@ public Builder context(Map<String, Object> context) {
return this;
}

/** Names the approved hold spent by an exact retry. */
public Builder approvalId(String approvalId) {
this.approvalId = approvalId;
return this;
}

/**
* Builds the {@link DecideRequest}.
*
Expand Down
76 changes: 73 additions & 3 deletions src/main/java/com/getaxonflow/sdk/types/DecideResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public final class DecideResponse {
@JsonProperty("document_version")
private final Integer documentVersion;

@JsonProperty("pending_approval")
private final DecisionPendingApproval pendingApproval;

@JsonProperty("approval_id")
private final String approvalId;

/**
* Creates a decide response, as Jackson reads it from the wire (v11.0.0 shape).
*
Expand Down Expand Up @@ -110,7 +116,9 @@ public DecideResponse(
@JsonProperty("legacy_validators") List<LegacyValidatorAction> legacyValidators,
@JsonProperty("policy_identities") List<PolicyIdentity> policyIdentities,
@JsonProperty("policy_packs") List<String> policyPacks,
@JsonProperty("document_version") Integer documentVersion) {
@JsonProperty("document_version") Integer documentVersion,
@JsonProperty("pending_approval") DecisionPendingApproval pendingApproval,
@JsonProperty("approval_id") String approvalId) {
this.verdict = verdict;
this.decisionId = decisionId;
this.traceId = traceId;
Expand Down Expand Up @@ -143,6 +151,47 @@ public DecideResponse(
? Collections.unmodifiableList(new ArrayList<>(policyPacks))
: Collections.emptyList();
this.documentVersion = documentVersion;
this.pendingApproval = pendingApproval;
this.approvalId = approvalId;
}

/** Source compatible constructor retaining the v11.0 provenance shape. */
public DecideResponse(
String verdict,
String decisionId,
String traceId,
List<String> reasons,
List<Obligation> obligations,
List<String> evaluatedPolicies,
String stage,
Instant expiresAt,
String error,
String engine,
String subjectType,
String policyBundle,
List<LegacyValidatorAction> legacyValidators,
List<PolicyIdentity> policyIdentities,
List<String> policyPacks,
Integer documentVersion) {
this(
verdict,
decisionId,
traceId,
reasons,
obligations,
evaluatedPolicies,
stage,
expiresAt,
error,
engine,
subjectType,
policyBundle,
legacyValidators,
policyIdentities,
policyPacks,
documentVersion,
null,
null);
}

/**
Expand Down Expand Up @@ -184,6 +233,8 @@ public DecideResponse(
null,
null,
null,
null,
null,
null);
}

Expand Down Expand Up @@ -279,6 +330,16 @@ public Integer getDocumentVersion() {
return documentVersion;
}

/** The pending human review; callers must not execute while this is present. */
public DecisionPendingApproval getPendingApproval() {
return pendingApproval;
}

/** The approval consumed by an allowed retry, when present. */
public String getApprovalId() {
return approvalId;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -299,7 +360,9 @@ public boolean equals(Object o) {
&& Objects.equals(legacyValidators, that.legacyValidators)
&& Objects.equals(policyIdentities, that.policyIdentities)
&& Objects.equals(policyPacks, that.policyPacks)
&& Objects.equals(documentVersion, that.documentVersion);
&& Objects.equals(documentVersion, that.documentVersion)
&& Objects.equals(pendingApproval, that.pendingApproval)
&& Objects.equals(approvalId, that.approvalId);
}

@Override
Expand All @@ -320,7 +383,9 @@ public int hashCode() {
legacyValidators,
policyIdentities,
policyPacks,
documentVersion);
documentVersion,
pendingApproval,
approvalId);
}

@Override
Expand Down Expand Up @@ -366,6 +431,11 @@ public String toString() {
+ policyPacks
+ ", documentVersion="
+ documentVersion
+ ", pendingApproval="
+ pendingApproval
+ ", approvalId='"
+ approvalId
+ '\''
+ '}';
}
}
129 changes: 129 additions & 0 deletions src/main/java/com/getaxonflow/sdk/types/DecisionPendingApproval.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Copyright 2026 AxonFlow
// SPDX-License-Identifier: MIT
package com.getaxonflow.sdk.types;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.Instant;
import java.util.Objects;

/** A Decision API call held for a person's review. A hold is never permission to forward. */
@JsonIgnoreProperties(ignoreUnknown = true)
public final class DecisionPendingApproval {
@JsonProperty("approval_id")
private final String approvalId;

@JsonProperty("status")
private final String status;

@JsonProperty("plane")
private final String plane;

@JsonProperty("expires_at")
private final Instant expiresAt;

@JsonProperty("retry")
private final Retry retry;

@JsonCreator
public DecisionPendingApproval(
@JsonProperty("approval_id") String approvalId,
@JsonProperty("status") String status,
@JsonProperty("plane") String plane,
@JsonProperty("expires_at") Instant expiresAt,
@JsonProperty("retry") Retry retry) {
this.approvalId = approvalId;
this.status = status;
this.plane = plane;
this.expiresAt = expiresAt;
this.retry = retry;
}

public String getApprovalId() {
return approvalId;
}

public String getStatus() {
return status;
}

public String getPlane() {
return plane;
}

public Instant getExpiresAt() {
return expiresAt;
}

public Retry getRetry() {
return retry;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof DecisionPendingApproval)) return false;
DecisionPendingApproval that = (DecisionPendingApproval) o;
return Objects.equals(approvalId, that.approvalId)
&& Objects.equals(status, that.status)
&& Objects.equals(plane, that.plane)
&& Objects.equals(expiresAt, that.expiresAt)
&& Objects.equals(retry, that.retry);
}

@Override
public int hashCode() {
return Objects.hash(approvalId, status, plane, expiresAt, retry);
}

/** The header, request argument, or body field that names a held call on retry. */
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Retry {
@JsonProperty("header")
private final String header;

@JsonProperty("argument")
private final String argument;

@JsonProperty("body_field")
private final String bodyField;

@JsonCreator
public Retry(
@JsonProperty("header") String header,
@JsonProperty("argument") String argument,
@JsonProperty("body_field") String bodyField) {
this.header = header;
this.argument = argument;
this.bodyField = bodyField;
}

public String getHeader() {
return header;
}

public String getArgument() {
return argument;
}

public String getBodyField() {
return bodyField;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Retry)) return false;
Retry that = (Retry) o;
return Objects.equals(header, that.header)
&& Objects.equals(argument, that.argument)
&& Objects.equals(bodyField, that.bodyField);
}

@Override
public int hashCode() {
return Objects.hash(header, argument, bodyField);
}
}
}
Loading
Loading