Six services, independently built then integrated: - services/wal (C): crash-safe write-ahead log, CRC32-checksummed frames, torn-write recovery via truncate-to-last-valid-frame. - services/ledger-core (Rust): double-entry ledger over the C WAL via FFI, reserve-floor enforcement BEFORE any WAL write, idempotent ApplyEntry, full LedgerCore gRPC service. - services/gateway (Go): Airwallex Issuing/Global-Accounts client (mock mode default, live mode ready), the actual rationing math (reserve floor, 60% bridge cap, 24h velocity cap, partial-over-decline). - services/agent (Go): deterministic hard-rule policy envelope computed BEFORE any LLM call; Claude only decides within that pre-approved envelope; every decision audit-logged even when the LLM call fails. - services/tui (Go, Bubble Tea) + services/cli (Go, cobra): the only UI — no web frontend, per explicit direction. Integration found and fixed three real bugs, not just compile errors: - proto regen collision shadowing checked-in pkg/pb packages - ledger-core/gateway address-variable mismatch (stack would never actually connect on default config) - the big one: MarkDepositReceived never credited the ledger, so every tenant's balance was permanently stuck at 0 and bridge-funding could only ever decline — the core agentic-rationing feature could never produce a real grant. Fixed at the ledger level with idempotent mark-and-credit in one WAL frame, covered by 3 new tests. End-to-end verified live, reproducibly: seed -> simulate a late deposit -> agent grants a partial bridge with a computed rationale -> second grant correctly declines once the 24h velocity cap engages. Verified independently by the orchestrator too: 'make build' and 'make test' both clean (Rust: 29 tests; Go: all packages; C: WAL test suite). Airwallex sandbox credentials still pending organizer approval — tracked as an owner blocker in docs/AIRWALLEX-SETUP.md, not a code gap.
389 lines
11 KiB
Go
389 lines
11 KiB
Go
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
// versions:
|
|
// protoc-gen-go v1.36.12
|
|
// protoc v6.33.4
|
|
// source: common.proto
|
|
|
|
package common
|
|
|
|
import (
|
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
reflect "reflect"
|
|
sync "sync"
|
|
unsafe "unsafe"
|
|
)
|
|
|
|
const (
|
|
// Verify that this generated code is sufficiently up-to-date.
|
|
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
|
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
)
|
|
|
|
type LedgerEntryType int32
|
|
|
|
const (
|
|
LedgerEntryType_LEDGER_ENTRY_TYPE_UNSPECIFIED LedgerEntryType = 0
|
|
LedgerEntryType_LEDGER_ENTRY_TYPE_CREDIT LedgerEntryType = 1
|
|
LedgerEntryType_LEDGER_ENTRY_TYPE_DEBIT LedgerEntryType = 2
|
|
LedgerEntryType_LEDGER_ENTRY_TYPE_HOLD LedgerEntryType = 3
|
|
LedgerEntryType_LEDGER_ENTRY_TYPE_RELEASE LedgerEntryType = 4
|
|
)
|
|
|
|
// Enum value maps for LedgerEntryType.
|
|
var (
|
|
LedgerEntryType_name = map[int32]string{
|
|
0: "LEDGER_ENTRY_TYPE_UNSPECIFIED",
|
|
1: "LEDGER_ENTRY_TYPE_CREDIT",
|
|
2: "LEDGER_ENTRY_TYPE_DEBIT",
|
|
3: "LEDGER_ENTRY_TYPE_HOLD",
|
|
4: "LEDGER_ENTRY_TYPE_RELEASE",
|
|
}
|
|
LedgerEntryType_value = map[string]int32{
|
|
"LEDGER_ENTRY_TYPE_UNSPECIFIED": 0,
|
|
"LEDGER_ENTRY_TYPE_CREDIT": 1,
|
|
"LEDGER_ENTRY_TYPE_DEBIT": 2,
|
|
"LEDGER_ENTRY_TYPE_HOLD": 3,
|
|
"LEDGER_ENTRY_TYPE_RELEASE": 4,
|
|
}
|
|
)
|
|
|
|
func (x LedgerEntryType) Enum() *LedgerEntryType {
|
|
p := new(LedgerEntryType)
|
|
*p = x
|
|
return p
|
|
}
|
|
|
|
func (x LedgerEntryType) String() string {
|
|
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
|
}
|
|
|
|
func (LedgerEntryType) Descriptor() protoreflect.EnumDescriptor {
|
|
return file_common_proto_enumTypes[0].Descriptor()
|
|
}
|
|
|
|
func (LedgerEntryType) Type() protoreflect.EnumType {
|
|
return &file_common_proto_enumTypes[0]
|
|
}
|
|
|
|
func (x LedgerEntryType) Number() protoreflect.EnumNumber {
|
|
return protoreflect.EnumNumber(x)
|
|
}
|
|
|
|
// Deprecated: Use LedgerEntryType.Descriptor instead.
|
|
func (LedgerEntryType) EnumDescriptor() ([]byte, []int) {
|
|
return file_common_proto_rawDescGZIP(), []int{0}
|
|
}
|
|
|
|
type DepositStatus int32
|
|
|
|
const (
|
|
DepositStatus_DEPOSIT_STATUS_UNSPECIFIED DepositStatus = 0
|
|
DepositStatus_DEPOSIT_STATUS_EXPECTED DepositStatus = 1
|
|
DepositStatus_DEPOSIT_STATUS_RECEIVED DepositStatus = 2
|
|
DepositStatus_DEPOSIT_STATUS_LATE DepositStatus = 3
|
|
)
|
|
|
|
// Enum value maps for DepositStatus.
|
|
var (
|
|
DepositStatus_name = map[int32]string{
|
|
0: "DEPOSIT_STATUS_UNSPECIFIED",
|
|
1: "DEPOSIT_STATUS_EXPECTED",
|
|
2: "DEPOSIT_STATUS_RECEIVED",
|
|
3: "DEPOSIT_STATUS_LATE",
|
|
}
|
|
DepositStatus_value = map[string]int32{
|
|
"DEPOSIT_STATUS_UNSPECIFIED": 0,
|
|
"DEPOSIT_STATUS_EXPECTED": 1,
|
|
"DEPOSIT_STATUS_RECEIVED": 2,
|
|
"DEPOSIT_STATUS_LATE": 3,
|
|
}
|
|
)
|
|
|
|
func (x DepositStatus) Enum() *DepositStatus {
|
|
p := new(DepositStatus)
|
|
*p = x
|
|
return p
|
|
}
|
|
|
|
func (x DepositStatus) String() string {
|
|
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
|
}
|
|
|
|
func (DepositStatus) Descriptor() protoreflect.EnumDescriptor {
|
|
return file_common_proto_enumTypes[1].Descriptor()
|
|
}
|
|
|
|
func (DepositStatus) Type() protoreflect.EnumType {
|
|
return &file_common_proto_enumTypes[1]
|
|
}
|
|
|
|
func (x DepositStatus) Number() protoreflect.EnumNumber {
|
|
return protoreflect.EnumNumber(x)
|
|
}
|
|
|
|
// Deprecated: Use DepositStatus.Descriptor instead.
|
|
func (DepositStatus) EnumDescriptor() ([]byte, []int) {
|
|
return file_common_proto_rawDescGZIP(), []int{1}
|
|
}
|
|
|
|
type CardStatus int32
|
|
|
|
const (
|
|
CardStatus_CARD_STATUS_UNSPECIFIED CardStatus = 0
|
|
CardStatus_CARD_STATUS_ACTIVE CardStatus = 1
|
|
CardStatus_CARD_STATUS_RATIONED CardStatus = 2 // spend capped below requested due to bridge funding
|
|
CardStatus_CARD_STATUS_SUSPENDED CardStatus = 3
|
|
CardStatus_CARD_STATUS_CLOSED CardStatus = 4
|
|
)
|
|
|
|
// Enum value maps for CardStatus.
|
|
var (
|
|
CardStatus_name = map[int32]string{
|
|
0: "CARD_STATUS_UNSPECIFIED",
|
|
1: "CARD_STATUS_ACTIVE",
|
|
2: "CARD_STATUS_RATIONED",
|
|
3: "CARD_STATUS_SUSPENDED",
|
|
4: "CARD_STATUS_CLOSED",
|
|
}
|
|
CardStatus_value = map[string]int32{
|
|
"CARD_STATUS_UNSPECIFIED": 0,
|
|
"CARD_STATUS_ACTIVE": 1,
|
|
"CARD_STATUS_RATIONED": 2,
|
|
"CARD_STATUS_SUSPENDED": 3,
|
|
"CARD_STATUS_CLOSED": 4,
|
|
}
|
|
)
|
|
|
|
func (x CardStatus) Enum() *CardStatus {
|
|
p := new(CardStatus)
|
|
*p = x
|
|
return p
|
|
}
|
|
|
|
func (x CardStatus) String() string {
|
|
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
|
}
|
|
|
|
func (CardStatus) Descriptor() protoreflect.EnumDescriptor {
|
|
return file_common_proto_enumTypes[2].Descriptor()
|
|
}
|
|
|
|
func (CardStatus) Type() protoreflect.EnumType {
|
|
return &file_common_proto_enumTypes[2]
|
|
}
|
|
|
|
func (x CardStatus) Number() protoreflect.EnumNumber {
|
|
return protoreflect.EnumNumber(x)
|
|
}
|
|
|
|
// Deprecated: Use CardStatus.Descriptor instead.
|
|
func (CardStatus) EnumDescriptor() ([]byte, []int) {
|
|
return file_common_proto_rawDescGZIP(), []int{2}
|
|
}
|
|
|
|
type AgentAction int32
|
|
|
|
const (
|
|
AgentAction_AGENT_ACTION_UNSPECIFIED AgentAction = 0
|
|
AgentAction_AGENT_ACTION_ISSUE_CARD AgentAction = 1
|
|
AgentAction_AGENT_ACTION_ADJUST_LIMIT AgentAction = 2
|
|
AgentAction_AGENT_ACTION_RATION_BRIDGE AgentAction = 3
|
|
AgentAction_AGENT_ACTION_RELEASE_HOLD AgentAction = 4
|
|
AgentAction_AGENT_ACTION_DECLINE AgentAction = 5
|
|
AgentAction_AGENT_ACTION_NOTIFY AgentAction = 6
|
|
)
|
|
|
|
// Enum value maps for AgentAction.
|
|
var (
|
|
AgentAction_name = map[int32]string{
|
|
0: "AGENT_ACTION_UNSPECIFIED",
|
|
1: "AGENT_ACTION_ISSUE_CARD",
|
|
2: "AGENT_ACTION_ADJUST_LIMIT",
|
|
3: "AGENT_ACTION_RATION_BRIDGE",
|
|
4: "AGENT_ACTION_RELEASE_HOLD",
|
|
5: "AGENT_ACTION_DECLINE",
|
|
6: "AGENT_ACTION_NOTIFY",
|
|
}
|
|
AgentAction_value = map[string]int32{
|
|
"AGENT_ACTION_UNSPECIFIED": 0,
|
|
"AGENT_ACTION_ISSUE_CARD": 1,
|
|
"AGENT_ACTION_ADJUST_LIMIT": 2,
|
|
"AGENT_ACTION_RATION_BRIDGE": 3,
|
|
"AGENT_ACTION_RELEASE_HOLD": 4,
|
|
"AGENT_ACTION_DECLINE": 5,
|
|
"AGENT_ACTION_NOTIFY": 6,
|
|
}
|
|
)
|
|
|
|
func (x AgentAction) Enum() *AgentAction {
|
|
p := new(AgentAction)
|
|
*p = x
|
|
return p
|
|
}
|
|
|
|
func (x AgentAction) String() string {
|
|
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
|
}
|
|
|
|
func (AgentAction) Descriptor() protoreflect.EnumDescriptor {
|
|
return file_common_proto_enumTypes[3].Descriptor()
|
|
}
|
|
|
|
func (AgentAction) Type() protoreflect.EnumType {
|
|
return &file_common_proto_enumTypes[3]
|
|
}
|
|
|
|
func (x AgentAction) Number() protoreflect.EnumNumber {
|
|
return protoreflect.EnumNumber(x)
|
|
}
|
|
|
|
// Deprecated: Use AgentAction.Descriptor instead.
|
|
func (AgentAction) EnumDescriptor() ([]byte, []int) {
|
|
return file_common_proto_rawDescGZIP(), []int{3}
|
|
}
|
|
|
|
// Money is always fixed-point minor units (e.g. cents) to avoid float drift.
|
|
type Money struct {
|
|
state protoimpl.MessageState `protogen:"open.v1"`
|
|
MinorUnits int64 `protobuf:"varint,1,opt,name=minor_units,json=minorUnits,proto3" json:"minor_units,omitempty"`
|
|
Currency string `protobuf:"bytes,2,opt,name=currency,proto3" json:"currency,omitempty"` // ISO 4217, e.g. "USD"
|
|
unknownFields protoimpl.UnknownFields
|
|
sizeCache protoimpl.SizeCache
|
|
}
|
|
|
|
func (x *Money) Reset() {
|
|
*x = Money{}
|
|
mi := &file_common_proto_msgTypes[0]
|
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
ms.StoreMessageInfo(mi)
|
|
}
|
|
|
|
func (x *Money) String() string {
|
|
return protoimpl.X.MessageStringOf(x)
|
|
}
|
|
|
|
func (*Money) ProtoMessage() {}
|
|
|
|
func (x *Money) ProtoReflect() protoreflect.Message {
|
|
mi := &file_common_proto_msgTypes[0]
|
|
if x != nil {
|
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
if ms.LoadMessageInfo() == nil {
|
|
ms.StoreMessageInfo(mi)
|
|
}
|
|
return ms
|
|
}
|
|
return mi.MessageOf(x)
|
|
}
|
|
|
|
// Deprecated: Use Money.ProtoReflect.Descriptor instead.
|
|
func (*Money) Descriptor() ([]byte, []int) {
|
|
return file_common_proto_rawDescGZIP(), []int{0}
|
|
}
|
|
|
|
func (x *Money) GetMinorUnits() int64 {
|
|
if x != nil {
|
|
return x.MinorUnits
|
|
}
|
|
return 0
|
|
}
|
|
|
|
func (x *Money) GetCurrency() string {
|
|
if x != nil {
|
|
return x.Currency
|
|
}
|
|
return ""
|
|
}
|
|
|
|
var File_common_proto protoreflect.FileDescriptor
|
|
|
|
const file_common_proto_rawDesc = "" +
|
|
"\n" +
|
|
"\fcommon.proto\x12\x10ration.common.v1\"D\n" +
|
|
"\x05Money\x12\x1f\n" +
|
|
"\vminor_units\x18\x01 \x01(\x03R\n" +
|
|
"minorUnits\x12\x1a\n" +
|
|
"\bcurrency\x18\x02 \x01(\tR\bcurrency*\xaa\x01\n" +
|
|
"\x0fLedgerEntryType\x12!\n" +
|
|
"\x1dLEDGER_ENTRY_TYPE_UNSPECIFIED\x10\x00\x12\x1c\n" +
|
|
"\x18LEDGER_ENTRY_TYPE_CREDIT\x10\x01\x12\x1b\n" +
|
|
"\x17LEDGER_ENTRY_TYPE_DEBIT\x10\x02\x12\x1a\n" +
|
|
"\x16LEDGER_ENTRY_TYPE_HOLD\x10\x03\x12\x1d\n" +
|
|
"\x19LEDGER_ENTRY_TYPE_RELEASE\x10\x04*\x82\x01\n" +
|
|
"\rDepositStatus\x12\x1e\n" +
|
|
"\x1aDEPOSIT_STATUS_UNSPECIFIED\x10\x00\x12\x1b\n" +
|
|
"\x17DEPOSIT_STATUS_EXPECTED\x10\x01\x12\x1b\n" +
|
|
"\x17DEPOSIT_STATUS_RECEIVED\x10\x02\x12\x17\n" +
|
|
"\x13DEPOSIT_STATUS_LATE\x10\x03*\x8e\x01\n" +
|
|
"\n" +
|
|
"CardStatus\x12\x1b\n" +
|
|
"\x17CARD_STATUS_UNSPECIFIED\x10\x00\x12\x16\n" +
|
|
"\x12CARD_STATUS_ACTIVE\x10\x01\x12\x18\n" +
|
|
"\x14CARD_STATUS_RATIONED\x10\x02\x12\x19\n" +
|
|
"\x15CARD_STATUS_SUSPENDED\x10\x03\x12\x16\n" +
|
|
"\x12CARD_STATUS_CLOSED\x10\x04*\xd9\x01\n" +
|
|
"\vAgentAction\x12\x1c\n" +
|
|
"\x18AGENT_ACTION_UNSPECIFIED\x10\x00\x12\x1b\n" +
|
|
"\x17AGENT_ACTION_ISSUE_CARD\x10\x01\x12\x1d\n" +
|
|
"\x19AGENT_ACTION_ADJUST_LIMIT\x10\x02\x12\x1e\n" +
|
|
"\x1aAGENT_ACTION_RATION_BRIDGE\x10\x03\x12\x1d\n" +
|
|
"\x19AGENT_ACTION_RELEASE_HOLD\x10\x04\x12\x18\n" +
|
|
"\x14AGENT_ACTION_DECLINE\x10\x05\x12\x17\n" +
|
|
"\x13AGENT_ACTION_NOTIFY\x10\x06B*Z(github.com/caelum0x/ration/pkg/pb/commonb\x06proto3"
|
|
|
|
var (
|
|
file_common_proto_rawDescOnce sync.Once
|
|
file_common_proto_rawDescData []byte
|
|
)
|
|
|
|
func file_common_proto_rawDescGZIP() []byte {
|
|
file_common_proto_rawDescOnce.Do(func() {
|
|
file_common_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_common_proto_rawDesc), len(file_common_proto_rawDesc)))
|
|
})
|
|
return file_common_proto_rawDescData
|
|
}
|
|
|
|
var file_common_proto_enumTypes = make([]protoimpl.EnumInfo, 4)
|
|
var file_common_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
|
var file_common_proto_goTypes = []any{
|
|
(LedgerEntryType)(0), // 0: ration.common.v1.LedgerEntryType
|
|
(DepositStatus)(0), // 1: ration.common.v1.DepositStatus
|
|
(CardStatus)(0), // 2: ration.common.v1.CardStatus
|
|
(AgentAction)(0), // 3: ration.common.v1.AgentAction
|
|
(*Money)(nil), // 4: ration.common.v1.Money
|
|
}
|
|
var file_common_proto_depIdxs = []int32{
|
|
0, // [0:0] is the sub-list for method output_type
|
|
0, // [0:0] is the sub-list for method input_type
|
|
0, // [0:0] is the sub-list for extension type_name
|
|
0, // [0:0] is the sub-list for extension extendee
|
|
0, // [0:0] is the sub-list for field type_name
|
|
}
|
|
|
|
func init() { file_common_proto_init() }
|
|
func file_common_proto_init() {
|
|
if File_common_proto != nil {
|
|
return
|
|
}
|
|
type x struct{}
|
|
out := protoimpl.TypeBuilder{
|
|
File: protoimpl.DescBuilder{
|
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
|
RawDescriptor: unsafe.Slice(unsafe.StringData(file_common_proto_rawDesc), len(file_common_proto_rawDesc)),
|
|
NumEnums: 4,
|
|
NumMessages: 1,
|
|
NumExtensions: 0,
|
|
NumServices: 0,
|
|
},
|
|
GoTypes: file_common_proto_goTypes,
|
|
DependencyIndexes: file_common_proto_depIdxs,
|
|
EnumInfos: file_common_proto_enumTypes,
|
|
MessageInfos: file_common_proto_msgTypes,
|
|
}.Build()
|
|
File_common_proto = out.File
|
|
file_common_proto_goTypes = nil
|
|
file_common_proto_depIdxs = nil
|
|
}
|