360 Secure SkillHub
360 安全技能中心

a2a-Market-Compute-Ledger

用于构建和运营 A2A 运行时中的计算账本模块,覆盖账户余额、冻结、扣费、释放、账本查询与计费事件;目前为脚手架级技能,提供最小接口契约、实现布局和测试线索,生产逻辑及审计工具仍待完善。

luoqianchenguni-max
luoqianchenguni-max
热度 51.95
最近更新 2026-05-11 17:33:38
分类:开发依赖:代码执行 / 读写文件应用场景:代码生成 / 财务 / 数据处理 / 工作流 ...

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add a2a-market-compute-ledger
Metadata
name
a2a-market-compute-ledger
description
Manage compute account ledgers, frozen balances, charge events, and settlement records for A2A commerce flows. Use when implementing or operating compute billing, debit, freeze, unfreeze, and audit trails.

a2a-Market Compute Ledger

Build and operate the compute ledger module for RealMarket A2A runtime.

Current status: scaffold-first skill for early registration. Keep APIs stable, add production logic incrementally.

Scope

  • Own ComputeAccount domain object, balance snapshots, and immutable transaction journal.
  • Support reserve/freeze before negotiation and final debit after order confirmation.
  • Emit billing events to event bus for reputation, websocket push, and finance logs.

Suggested Project Layout

  • app/domain/entities/compute_account.py
  • app/application/services/billing_service.py
  • app/infrastructure/db/ledger_repository.py
  • app/infrastructure/tasks/reconcile_ledger.py

Minimum Contracts (MVP P0)

  1. freeze(account_id, amount, reason) returns hold id and expiry.
  2. capture_hold(hold_id, order_id) converts hold to settled charge.
  3. release_hold(hold_id) unlocks unused balance.
  4. list_ledger_entries(account_id, from_ts, to_ts) returns ordered journal records.

Event Mapping

  • On hold created: emit INTENT_CREATED + billing extension payload.
  • On charge captured: emit ORDER_CREATED and settlement payload.
  • On charge finalized: emit PAYMENT_SUCCEEDED.

Guardrails

  • Use integer minor units for money; avoid float math.
  • Enforce idempotency key on every mutating operation.
  • Keep journal append-only; never rewrite posted entries.

Implementation Backlog

  • Add double-entry validation rules.
  • Add monthly statement export and audit tooling.

Runtime Implementation

  • Status: implemented in local runtime package.
  • Primary code paths:
  • runtime/src/domain/compute-ledger.js
  • Validation: covered by runtime/tests and npm test in runtime/.