PaymentApplicationService の実装(payment-service)

payment-servicePaymentApplicationService には AgentFactoryAgent も使われていません。依存するのは PaymentProfileRepository(支払い手段選択)と PaymentExecutionHistoryStore(実行履歴記録)だけです。

// PaymentApplicationService.java
@Service
public class PaymentApplicationService {

    private final PaymentProfileRepository repository;
    private final PaymentExecutionHistoryStore historyStore;

    public PaymentPrepareResponse prepare(PaymentPrepareRequest request) {
        long startedAt = System.nanoTime();
        PaymentProfile profile = repository.profileFor(request.instruction());
        boolean charged = request.confirmRequested();
        String authorizationId = charged
                ? "pay-" + UUID.randomUUID().toString().substring(0, 8) : null;
        String paymentStatus = charged ? "CHARGED" : "READY";
        String summary = repository.summarize(profile, charged);
        PaymentPrepareResponse response = new PaymentPrepareResponse(
                "payment-service",
                "payment-service",
                charged ? "支払い処理が完了しました" : "支払方法の準備が完了しました",
                summary,
                profile.methodLabel(),
                request.total().setScale(2, RoundingMode.HALF_UP),
                paymentStatus,
                charged,
                authorizationId);
        historyStore.append(
                request.sessionId(),
                charged ? "confirm-payment" : "prepare-payment",
                "success",
                (System.nanoTime() - startedAt) / 1_000_000,
                response.headline(),
                response.summary());
        return response;
    }
}

支払い金額は RoundingMode.HALF_UP で端数処理、承認 ID は UUID.randomUUID() で生成、課金判断は request.confirmRequested() のブール値で行います。AI の関与はありません。

pom.xml の構成(payment-service)

payment-service/pom.xml には arachne モジュールへの依存がありません。

<!-- payment-service/pom.xml (依存の抜粋) -->
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <!-- arachne への依存なし -->
</dependencies>

観察された振る舞い

  • payment-service からエージェントを除いた後、起動時例外が消え、compose 全体が安定して起動するようになった。
  • 4 ステップの注文フローを通して payment-service は一貫して動作した。
  • 同じ sessionId の実行履歴(/execution-history/{sessionId})を確認すると、payment-service のエントリには LLM 呼び出しやツール実行の記録がなく、prepare-payment / confirm-payment の決定論的な記録のみが残っていた。
  • 支払い金額の端数処理と承認 ID 生成はコードの中に明示的に書かれており、AI が介在する余地がなかった。

ランタイム比較: payment-service vs order-service の実行履歴

payment-service の応答(Apple Pay 準備)

POST /internal/payment/prepare{"sessionId":"obs-payment-001","instruction":{"rawMessage":"Apple Pay で支払います","requestedMethod":"APPLE_PAY"},"total":1290.00,"confirmRequested":false} を送信した実際のレスポンスです。

{
  "service": "payment-service",
  "agent": "payment-service",
  "headline": "支払方法の準備が完了しました",
  "summary": "Apple Pay を選択しました。メインの iPhone のウォレットに登録済みです。",
  "selectedMethod": "Apple Pay",
  "total": 1290.0,
  "paymentStatus": "READY",
  "charged": false,
  "authorizationId": null
}

agent フィールドが "payment-service" — サービス名そのものです。"payment-agent" ではありません。

payment-service の実行履歴

{
  "sessionId": "obs-payment-001",
  "events": [
    {
      "sequence": 1,
      "category": "service",
      "service": "payment-service",
      "component": "payment-service",
      "operation": "prepare-payment",
      "outcome": "success",
      "durationMs": 2,
      "headline": "支払方法の準備が完了しました",
      "detail": "Apple Pay を選択しました。メインの iPhone のウォレットに登録済みです。"
    }
  ]
}

category: "service" のイベントが 1 件だけ、durationMs: 2(2 ミリ秒)で完了しています。LLM 呼び出しを示す category: "agent" のイベントは存在しません。

比較: order-service の実行履歴(同一ターンの suggest 呼び出し)

{
  "sessionId": "session-405162fd",
  "events": [
    {
      "sequence": 9,
      "category": "agent",
      "component": "order-intake-agent",
      "operation": "invoke",
      "outcome": "started",
      "durationMs": 0
    },
    {
      "sequence": 10,
      "category": "agent",
      "component": "order-intake-agent",
      "operation": "invoke",
      "outcome": "success",
      "durationMs": 2631
    }
  ]
}

order-service の category: "agent" は LLM 呼び出しに対応し、durationMs: 2631(約 2.6 秒)のレイテンシがあります。payment-service の 2 ミリ秒と対照的です。

確認できる場所

  • payment-service/v3/api-docs(エージェント関連フィールドが存在しないことを確認できる)
  • order-service の実行履歴(confirm-payment ステップ)
  • /agents ページの payment-service カード(systemPrompt が “決定的な支払い手段選択と請求処理を提供する” という静的記述のみ)