xytara 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +29 -0
- package/BSV_TERANODE_SETUP.md +43 -0
- package/README.md +66 -7
- package/REAL_PAYMENT_SETUP.md +61 -0
- package/RELEASE_NOTES.md +12 -6
- package/SERVICE_CONTRACT.md +31 -0
- package/START_HERE.md +107 -6
- package/TREASURY_DESTINATIONS.example.json +66 -0
- package/TREASURY_DESTINATIONS.production.template.json +108 -0
- package/adapters/examples/langchain-reference-execution-adapter.js +81 -0
- package/adapters/examples/langchain-reference-execution-adapter.manifest.json +79 -0
- package/adapters/examples/langgraph-reference-execution-adapter.js +81 -0
- package/adapters/examples/langgraph-reference-execution-adapter.manifest.json +79 -0
- package/bin/xytara-first-run.js +244 -0
- package/bin/xytara.js +30 -5
- package/integrations/dispatch.js +7 -2
- package/integrations/registry.js +123 -2
- package/lib/activity_audit_contract.js +322 -0
- package/lib/adapter_depth_contract.js +156 -0
- package/lib/bolt_lane_contract.js +55 -0
- package/lib/bolt_payment_front.js +172 -0
- package/lib/capability_execution_truth.js +269 -0
- package/lib/capability_registry.js +39 -2
- package/lib/checkout_event_security.js +142 -0
- package/lib/command_flow.js +169 -36
- package/lib/commerce_artifacts.js +23 -4
- package/lib/commerce_checkout.js +134 -4
- package/lib/commerce_client.js +20 -0
- package/lib/commerce_economics.js +109 -9
- package/lib/commerce_runtime.js +38 -2
- package/lib/commerce_shell.js +4 -2
- package/lib/external_execution_runtime.js +132 -0
- package/lib/go_live_operator_pack.js +339 -0
- package/lib/http_transport.js +32 -0
- package/lib/integration_matrix_contract.js +6 -0
- package/lib/l402_lane_contract.js +55 -0
- package/lib/l402_payment_front.js +192 -0
- package/lib/network_transport.js +110 -0
- package/lib/operator_intelligence.js +215 -1
- package/lib/payment_config.js +80 -3
- package/lib/payment_front_registry.js +53 -0
- package/lib/payment_protocol_contract.js +165 -0
- package/lib/payment_verification.js +23 -3
- package/lib/pricing_optimization_contract.js +556 -0
- package/lib/release_history.js +15 -0
- package/lib/request_rate_limit.js +144 -0
- package/lib/runtime_bridge.js +10 -2
- package/lib/runtime_operations_worker.js +282 -0
- package/lib/settlement_bsv_live.js +79 -4
- package/lib/stripe_mpp_lane_contract.js +3 -0
- package/lib/stripe_mpp_payment_front.js +158 -0
- package/lib/treasury_destinations_contract.js +543 -0
- package/lib/treasury_egress_policy_contract.js +91 -0
- package/package.json +14 -21
- package/server.js +627 -88
- package/OPERATIONS_RUNBOOK.md +0 -66
- package/OPERATOR_START_HERE.md +0 -63
- package/PROGRAM_COMPLETE_RELEASE.md +0 -63
- package/PROGRAM_STATUS.md +0 -57
- package/PUBLISH_PLAN.md +0 -14
- package/RELEASE_CHECKLIST.md +0 -16
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { buildConfiguredTreasuryDestination, loadPaymentConfig } = require("./payment_config");
|
|
4
|
+
const {
|
|
5
|
+
buildBsvTeranodeTreasuryDestination,
|
|
6
|
+
loadBsvTeranodeConfig
|
|
7
|
+
} = require("./settlement_bsv_teranode");
|
|
8
|
+
|
|
9
|
+
const RAIL_PROFILES = [
|
|
10
|
+
{
|
|
11
|
+
rail_id: "bsv_teranode",
|
|
12
|
+
settlement_mode: "bsv_teranode",
|
|
13
|
+
reserve_role: "strategic_native_treasury",
|
|
14
|
+
compliance_posture: "public_native_treasury_identity_allowed",
|
|
15
|
+
required_fields: ["destination_id", "destination_kind", "external_ref"],
|
|
16
|
+
recommended_fields: ["network", "custody_ref", "reporting_ref", "wallet_ref", "provider_ref", "storage_class"],
|
|
17
|
+
config_template: {
|
|
18
|
+
destination_id: "treasury_bsv_main",
|
|
19
|
+
destination_kind: "bsv_teranode_address",
|
|
20
|
+
external_ref: "1ExampleMerchantAddress",
|
|
21
|
+
custody_ref: "vault.bsv.primary",
|
|
22
|
+
reporting_ref: "ledger.bsv.primary",
|
|
23
|
+
wallet_ref: "wallet.bsv.primary",
|
|
24
|
+
provider_ref: "arc.bsv.primary",
|
|
25
|
+
network: "mainnet",
|
|
26
|
+
storage_class: "cold_primary"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
rail_id: "evm",
|
|
31
|
+
settlement_mode: "evm",
|
|
32
|
+
reserve_role: "canonical_contract_settlement",
|
|
33
|
+
compliance_posture: "public_settlement_destination_allowed",
|
|
34
|
+
required_fields: ["destination_id", "destination_kind", "external_ref", "chain_id"],
|
|
35
|
+
recommended_fields: ["custody_ref", "reporting_ref", "wallet_ref", "provider_ref", "storage_class"],
|
|
36
|
+
config_template: {
|
|
37
|
+
destination_id: "treasury_evm_main",
|
|
38
|
+
destination_kind: "evm_address",
|
|
39
|
+
external_ref: "0xTreasuryAddress",
|
|
40
|
+
chain_id: "1",
|
|
41
|
+
custody_ref: "vault.evm.primary",
|
|
42
|
+
reporting_ref: "ledger.evm.primary",
|
|
43
|
+
provider_ref: "rpc.evm.primary",
|
|
44
|
+
storage_class: "warm_operational"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
rail_id: "base",
|
|
49
|
+
settlement_mode: "base",
|
|
50
|
+
reserve_role: "canonical_low-friction_evm_settlement",
|
|
51
|
+
compliance_posture: "public_settlement_destination_allowed",
|
|
52
|
+
required_fields: ["destination_id", "destination_kind", "external_ref", "chain_id"],
|
|
53
|
+
recommended_fields: ["custody_ref", "reporting_ref", "wallet_ref", "provider_ref", "storage_class"],
|
|
54
|
+
config_template: {
|
|
55
|
+
destination_id: "treasury_base_main",
|
|
56
|
+
destination_kind: "evm_address",
|
|
57
|
+
external_ref: "0xBaseTreasuryAddress",
|
|
58
|
+
chain_id: "8453",
|
|
59
|
+
custody_ref: "vault.base.primary",
|
|
60
|
+
reporting_ref: "ledger.base.primary",
|
|
61
|
+
provider_ref: "rpc.base.primary",
|
|
62
|
+
storage_class: "warm_operational"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
rail_id: "solana_payment",
|
|
67
|
+
settlement_mode: "solana_payment",
|
|
68
|
+
reserve_role: "major_alternative_rail_settlement",
|
|
69
|
+
compliance_posture: "public_settlement_destination_allowed",
|
|
70
|
+
required_fields: ["destination_id", "destination_kind", "external_ref", "network"],
|
|
71
|
+
recommended_fields: ["custody_ref", "reporting_ref", "wallet_ref", "provider_ref", "asset_symbol", "storage_class"],
|
|
72
|
+
config_template: {
|
|
73
|
+
destination_id: "treasury_solana_main",
|
|
74
|
+
destination_kind: "solana_address",
|
|
75
|
+
external_ref: "ExampleSolanaTreasuryAddress",
|
|
76
|
+
network: "mainnet-beta",
|
|
77
|
+
asset_symbol: "SOL_OR_SPL",
|
|
78
|
+
custody_ref: "vault.solana.primary",
|
|
79
|
+
reporting_ref: "ledger.solana.primary",
|
|
80
|
+
wallet_ref: "wallet.solana.primary",
|
|
81
|
+
provider_ref: "rpc.solana.primary",
|
|
82
|
+
storage_class: "warm_operational"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
rail_id: "xpr_payment",
|
|
87
|
+
settlement_mode: "xpr_payment",
|
|
88
|
+
reserve_role: "major_alternative_rail_settlement",
|
|
89
|
+
compliance_posture: "public_settlement_destination_allowed",
|
|
90
|
+
required_fields: ["destination_id", "destination_kind", "external_ref", "network"],
|
|
91
|
+
recommended_fields: ["custody_ref", "reporting_ref", "wallet_ref", "provider_ref", "asset_symbol", "storage_class"],
|
|
92
|
+
config_template: {
|
|
93
|
+
destination_id: "treasury_xpr_main",
|
|
94
|
+
destination_kind: "proton_xpr_account",
|
|
95
|
+
external_ref: "examplexpracct",
|
|
96
|
+
network: "mainnet",
|
|
97
|
+
asset_symbol: "XPR",
|
|
98
|
+
custody_ref: "vault.xpr.primary",
|
|
99
|
+
reporting_ref: "ledger.xpr.primary",
|
|
100
|
+
wallet_ref: "wallet.xpr.primary",
|
|
101
|
+
provider_ref: "rpc.xpr.primary",
|
|
102
|
+
storage_class: "warm_operational"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
rail_id: "antelope_payment",
|
|
107
|
+
settlement_mode: "antelope_payment",
|
|
108
|
+
reserve_role: "major_alternative_rail_settlement",
|
|
109
|
+
compliance_posture: "public_settlement_destination_allowed",
|
|
110
|
+
required_fields: ["destination_id", "destination_kind", "external_ref", "network"],
|
|
111
|
+
recommended_fields: ["custody_ref", "reporting_ref", "wallet_ref", "provider_ref", "asset_symbol", "storage_class"],
|
|
112
|
+
config_template: {
|
|
113
|
+
destination_id: "treasury_antelope_main",
|
|
114
|
+
destination_kind: "antelope_account",
|
|
115
|
+
external_ref: "exampleeosacct",
|
|
116
|
+
network: "mainnet",
|
|
117
|
+
asset_symbol: "EOSIO_OR_ANTILOPE",
|
|
118
|
+
custody_ref: "vault.antelope.primary",
|
|
119
|
+
reporting_ref: "ledger.antelope.primary",
|
|
120
|
+
wallet_ref: "wallet.antelope.primary",
|
|
121
|
+
provider_ref: "rpc.antelope.primary",
|
|
122
|
+
storage_class: "warm_operational"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
rail_id: "usdc",
|
|
127
|
+
settlement_mode: "usdc",
|
|
128
|
+
reserve_role: "stable_operating_reserve",
|
|
129
|
+
compliance_posture: "public_stable_reserve_allowed",
|
|
130
|
+
required_fields: ["destination_id", "destination_kind", "external_ref", "asset_symbol"],
|
|
131
|
+
recommended_fields: ["chain_id", "custody_ref", "reporting_ref", "wallet_ref", "storage_class"],
|
|
132
|
+
config_template: {
|
|
133
|
+
destination_id: "treasury_usdc_primary",
|
|
134
|
+
destination_kind: "stablecoin_address",
|
|
135
|
+
external_ref: "0xUsdcTreasuryAddress",
|
|
136
|
+
asset_symbol: "USDC",
|
|
137
|
+
chain_id: "8453",
|
|
138
|
+
custody_ref: "vault.usdc.primary",
|
|
139
|
+
reporting_ref: "ledger.usdc.primary",
|
|
140
|
+
storage_class: "warm_operational"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
rail_id: "dai",
|
|
145
|
+
settlement_mode: "dai",
|
|
146
|
+
reserve_role: "stable_operating_reserve",
|
|
147
|
+
compliance_posture: "public_stable_reserve_allowed",
|
|
148
|
+
required_fields: ["destination_id", "destination_kind", "external_ref", "asset_symbol"],
|
|
149
|
+
recommended_fields: ["chain_id", "custody_ref", "reporting_ref", "wallet_ref", "storage_class"],
|
|
150
|
+
config_template: {
|
|
151
|
+
destination_id: "treasury_dai_primary",
|
|
152
|
+
destination_kind: "stablecoin_address",
|
|
153
|
+
external_ref: "0xDaiTreasuryAddress",
|
|
154
|
+
asset_symbol: "DAI",
|
|
155
|
+
chain_id: "1",
|
|
156
|
+
custody_ref: "vault.dai.primary",
|
|
157
|
+
reporting_ref: "ledger.dai.primary",
|
|
158
|
+
storage_class: "warm_operational"
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
rail_id: "monero",
|
|
163
|
+
settlement_mode: "monero",
|
|
164
|
+
reserve_role: "optional_hidden_privacy_reserve",
|
|
165
|
+
compliance_posture: "internal_only_policy_gated",
|
|
166
|
+
required_fields: ["destination_id", "destination_kind", "external_ref", "policy_scope"],
|
|
167
|
+
recommended_fields: ["custody_ref", "reporting_ref", "storage_class"],
|
|
168
|
+
config_template: {
|
|
169
|
+
destination_id: "treasury_monero_private",
|
|
170
|
+
destination_kind: "monero_address",
|
|
171
|
+
external_ref: "8ExampleMoneroAddress",
|
|
172
|
+
policy_scope: "internal_optional_privacy_reserve",
|
|
173
|
+
custody_ref: "vault.monero.policy_gated",
|
|
174
|
+
reporting_ref: "ledger.monero.internal",
|
|
175
|
+
storage_class: "isolated_policy_gated"
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
function classifyDestinationSource(profile, paymentConfig) {
|
|
181
|
+
const settlementMode = profile.settlement_mode;
|
|
182
|
+
const mapEntry = paymentConfig.treasury_destinations_by_settlement_mode[settlementMode];
|
|
183
|
+
if (mapEntry && mapEntry.destination_id) {
|
|
184
|
+
return "per_settlement_mode";
|
|
185
|
+
}
|
|
186
|
+
if (settlementMode === "bsv_teranode" && buildBsvTeranodeTreasuryDestination("acct_treasury_operator", settlementMode)) {
|
|
187
|
+
return "bsv_merchant_destination";
|
|
188
|
+
}
|
|
189
|
+
if (paymentConfig.treasury_destination_id) {
|
|
190
|
+
return "global_default";
|
|
191
|
+
}
|
|
192
|
+
return "unconfigured";
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function buildFieldValueMap(destination, bsvConfig) {
|
|
196
|
+
return {
|
|
197
|
+
destination_id: destination && destination.destination_id ? destination.destination_id : null,
|
|
198
|
+
destination_kind: destination && destination.destination_kind ? destination.destination_kind : null,
|
|
199
|
+
external_ref: destination && destination.external_ref ? destination.external_ref : null,
|
|
200
|
+
custody_ref: destination && destination.custody_ref ? destination.custody_ref : null,
|
|
201
|
+
reporting_ref: destination && destination.reporting_ref ? destination.reporting_ref : null,
|
|
202
|
+
wallet_ref: destination && destination.wallet_ref ? destination.wallet_ref : null,
|
|
203
|
+
provider_ref: destination && destination.provider_ref ? destination.provider_ref : null,
|
|
204
|
+
network: destination && destination.network ? destination.network : (bsvConfig && bsvConfig.network ? bsvConfig.network : null),
|
|
205
|
+
chain_id: destination && destination.chain_id ? destination.chain_id : null,
|
|
206
|
+
asset_symbol: destination && destination.asset_symbol ? destination.asset_symbol : null,
|
|
207
|
+
policy_scope: destination && destination.policy_scope ? destination.policy_scope : null,
|
|
208
|
+
storage_class: destination && destination.storage_class ? destination.storage_class : null
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function listMissingFields(fieldNames, values) {
|
|
213
|
+
return fieldNames.filter((fieldName) => !values[fieldName]);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function buildReadinessState(source, requiredMissingFields) {
|
|
217
|
+
if (source === "per_settlement_mode" && requiredMissingFields.length === 0) {
|
|
218
|
+
return "explicit_per-rail_ready";
|
|
219
|
+
}
|
|
220
|
+
if (source === "bsv_merchant_destination" && requiredMissingFields.length === 0) {
|
|
221
|
+
return "native_bsv_ready";
|
|
222
|
+
}
|
|
223
|
+
if (source === "global_default" && requiredMissingFields.length === 0) {
|
|
224
|
+
return "fallback_only_not_explicitly_per-rail";
|
|
225
|
+
}
|
|
226
|
+
if (source === "unconfigured") {
|
|
227
|
+
return "unconfigured";
|
|
228
|
+
}
|
|
229
|
+
return "partially_configured";
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function buildClaimDiscipline(profile, source, readinessState, configured, missingRecommendedFields) {
|
|
233
|
+
const internalOnly = profile.compliance_posture === "internal_only_policy_gated";
|
|
234
|
+
const reportingGaps = Array.isArray(missingRecommendedFields) && missingRecommendedFields.length > 0;
|
|
235
|
+
let publicClaimStatus = "readiness_template_only";
|
|
236
|
+
if (internalOnly) {
|
|
237
|
+
publicClaimStatus = "internal_policy_gated_not_public";
|
|
238
|
+
} else if (configured && reportingGaps) {
|
|
239
|
+
publicClaimStatus = "live_landing_path_with_operator_reporting_gaps";
|
|
240
|
+
} else if (configured) {
|
|
241
|
+
publicClaimStatus = "live_operational_landing_path";
|
|
242
|
+
} else if (source === "global_default") {
|
|
243
|
+
publicClaimStatus = "fallback_not_public_multi-rail_claim";
|
|
244
|
+
} else if (readinessState === "partially_configured") {
|
|
245
|
+
publicClaimStatus = "partial_configuration_not_public_claim";
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const publicClaimAllowed = !internalOnly && configured;
|
|
249
|
+
return {
|
|
250
|
+
public_claim_status: publicClaimStatus,
|
|
251
|
+
public_claim_allowed: publicClaimAllowed,
|
|
252
|
+
operator_claim_allowed: configured,
|
|
253
|
+
launch_claim_role: profile.rail_id === "bsv_teranode"
|
|
254
|
+
? "launch_primary_native_settlement"
|
|
255
|
+
: internalOnly
|
|
256
|
+
? "internal_optional_reserve"
|
|
257
|
+
: "future_or_optional_rail",
|
|
258
|
+
claim_guidance: publicClaimAllowed
|
|
259
|
+
? reportingGaps
|
|
260
|
+
? "can_claim_as_configured_with_operator_reporting_gaps_disclosed"
|
|
261
|
+
: "can_claim_as_configured_live_landing_path"
|
|
262
|
+
: internalOnly
|
|
263
|
+
? "do_not_make_public_landing_claim"
|
|
264
|
+
: "keep_as_supported_architecture_or_readiness_template_until_real_destination_is_configured",
|
|
265
|
+
reporting_gap_fields: reportingGaps ? missingRecommendedFields : []
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function buildOperatorNextSteps(requiredMissingFields, recommendedMissingFields, claimDiscipline) {
|
|
270
|
+
const steps = [];
|
|
271
|
+
if (requiredMissingFields.length > 0) {
|
|
272
|
+
steps.push("fill_missing_required_destination_fields_before_any_live_claim");
|
|
273
|
+
}
|
|
274
|
+
if (claimDiscipline.public_claim_status === "fallback_not_public_multi-rail_claim") {
|
|
275
|
+
steps.push("replace_global_fallback_with_per-rail_destination_before_public_multi-rail_claim");
|
|
276
|
+
}
|
|
277
|
+
if (claimDiscipline.public_claim_status === "internal_policy_gated_not_public") {
|
|
278
|
+
steps.push("keep_internal_only_and_policy_gated");
|
|
279
|
+
}
|
|
280
|
+
if (recommendedMissingFields.length > 0) {
|
|
281
|
+
steps.push("add_recommended_custody_reporting_wallet_provider_or_storage_refs");
|
|
282
|
+
}
|
|
283
|
+
return steps.length ? steps : ["keep_destination_under_periodic_operator_review"];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function buildTreasuryDestinationProfile(profile) {
|
|
287
|
+
const paymentConfig = loadPaymentConfig();
|
|
288
|
+
const destination = buildConfiguredTreasuryDestination("acct_treasury_operator", profile.settlement_mode);
|
|
289
|
+
const source = classifyDestinationSource(profile, paymentConfig);
|
|
290
|
+
const bsvConfig = profile.settlement_mode === "bsv_teranode" ? loadBsvTeranodeConfig() : null;
|
|
291
|
+
const fieldValues = buildFieldValueMap(destination, bsvConfig);
|
|
292
|
+
const requiredMissingFields = listMissingFields(profile.required_fields, fieldValues);
|
|
293
|
+
const recommendedMissingFields = listMissingFields(profile.recommended_fields, fieldValues);
|
|
294
|
+
const readinessState = buildReadinessState(source, requiredMissingFields);
|
|
295
|
+
const configured = readinessState === "explicit_per-rail_ready" || readinessState === "native_bsv_ready";
|
|
296
|
+
const claimDiscipline = buildClaimDiscipline(profile, source, readinessState, configured, recommendedMissingFields);
|
|
297
|
+
return {
|
|
298
|
+
rail_id: profile.rail_id,
|
|
299
|
+
settlement_mode: profile.settlement_mode,
|
|
300
|
+
reserve_role: profile.reserve_role,
|
|
301
|
+
compliance_posture: profile.compliance_posture,
|
|
302
|
+
configured,
|
|
303
|
+
configuration_source: source,
|
|
304
|
+
readiness_state: readinessState,
|
|
305
|
+
public_claim_status: claimDiscipline.public_claim_status,
|
|
306
|
+
public_claim_allowed: claimDiscipline.public_claim_allowed,
|
|
307
|
+
operator_claim_allowed: claimDiscipline.operator_claim_allowed,
|
|
308
|
+
launch_claim_role: claimDiscipline.launch_claim_role,
|
|
309
|
+
claim_guidance: claimDiscipline.claim_guidance,
|
|
310
|
+
reporting_gap_fields: claimDiscipline.reporting_gap_fields,
|
|
311
|
+
explicit_per_rail_configured: source === "per_settlement_mode" && requiredMissingFields.length === 0,
|
|
312
|
+
field_requirements: {
|
|
313
|
+
required_fields: profile.required_fields,
|
|
314
|
+
recommended_fields: profile.recommended_fields,
|
|
315
|
+
missing_required_fields: requiredMissingFields,
|
|
316
|
+
missing_recommended_fields: recommendedMissingFields
|
|
317
|
+
},
|
|
318
|
+
custody_destination: destination && destination.destination_id ? {
|
|
319
|
+
destination_id: destination.destination_id,
|
|
320
|
+
destination_kind: destination.destination_kind,
|
|
321
|
+
account_id: destination.account_id,
|
|
322
|
+
external_ref: destination.external_ref || null,
|
|
323
|
+
custody_ref: destination.custody_ref || null,
|
|
324
|
+
reporting_ref: destination.reporting_ref || null,
|
|
325
|
+
wallet_ref: destination.wallet_ref || null,
|
|
326
|
+
provider_ref: destination.provider_ref || null,
|
|
327
|
+
network: destination.network || null,
|
|
328
|
+
chain_id: destination.chain_id || null,
|
|
329
|
+
asset_symbol: destination.asset_symbol || null,
|
|
330
|
+
policy_scope: destination.policy_scope || null,
|
|
331
|
+
storage_class: destination.storage_class || null
|
|
332
|
+
} : null,
|
|
333
|
+
runtime_claim_readiness: configured
|
|
334
|
+
? "operational_claim_ready"
|
|
335
|
+
: source === "global_default"
|
|
336
|
+
? "fallback_present_but_do_not_claim_explicit_multi-rail_landing_yet"
|
|
337
|
+
: "do_not_claim_as_live_landing_destination_yet",
|
|
338
|
+
operator_next_steps: buildOperatorNextSteps(requiredMissingFields, recommendedMissingFields, claimDiscipline),
|
|
339
|
+
config_template: profile.config_template,
|
|
340
|
+
rail_metadata: bsvConfig ? {
|
|
341
|
+
network: bsvConfig.network,
|
|
342
|
+
merchant_address: bsvConfig.merchant_address,
|
|
343
|
+
merchant_paymail: bsvConfig.merchant_paymail
|
|
344
|
+
} : null,
|
|
345
|
+
guardrails: profile.rail_id === "monero"
|
|
346
|
+
? [
|
|
347
|
+
"internal_only",
|
|
348
|
+
"not_public_treasury_identity",
|
|
349
|
+
"must_not_weaken_reporting_or_accounting_surfaces",
|
|
350
|
+
"policy_scope_must_be_explicit_before_operational_use"
|
|
351
|
+
]
|
|
352
|
+
: [
|
|
353
|
+
"treasury_visibility_must_flow_back_into_xytara_ledger_and_reporting",
|
|
354
|
+
"custody_destination_should_be_secure_before_operational_claims_are_made",
|
|
355
|
+
"per-rail_config_is_preferred_over_global_fallback_for_public_operational_claims"
|
|
356
|
+
]
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function sanitizeTreasuryDestinationProfile(profile) {
|
|
361
|
+
return {
|
|
362
|
+
rail_id: profile.rail_id,
|
|
363
|
+
settlement_mode: profile.settlement_mode,
|
|
364
|
+
reserve_role: profile.reserve_role,
|
|
365
|
+
compliance_posture: profile.compliance_posture,
|
|
366
|
+
configured: profile.configured,
|
|
367
|
+
configuration_source: profile.configuration_source,
|
|
368
|
+
readiness_state: profile.readiness_state,
|
|
369
|
+
public_claim_status: profile.public_claim_status,
|
|
370
|
+
public_claim_allowed: profile.public_claim_allowed,
|
|
371
|
+
launch_claim_role: profile.launch_claim_role,
|
|
372
|
+
claim_guidance: profile.claim_guidance,
|
|
373
|
+
reporting_gap_fields: profile.reporting_gap_fields,
|
|
374
|
+
explicit_per_rail_configured: profile.explicit_per_rail_configured,
|
|
375
|
+
field_requirements: profile.field_requirements,
|
|
376
|
+
destination_visibility: {
|
|
377
|
+
destination_kind: profile.custody_destination ? profile.custody_destination.destination_kind : null,
|
|
378
|
+
network: profile.custody_destination ? profile.custody_destination.network : null,
|
|
379
|
+
chain_id: profile.custody_destination ? profile.custody_destination.chain_id : null,
|
|
380
|
+
asset_symbol: profile.custody_destination ? profile.custody_destination.asset_symbol : null,
|
|
381
|
+
policy_scope: profile.custody_destination ? profile.custody_destination.policy_scope : null,
|
|
382
|
+
storage_class: profile.custody_destination ? profile.custody_destination.storage_class : null
|
|
383
|
+
},
|
|
384
|
+
runtime_claim_readiness: profile.runtime_claim_readiness,
|
|
385
|
+
config_template: profile.config_template,
|
|
386
|
+
guardrails: profile.guardrails
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function buildOperatorTreasuryDestinationsPack() {
|
|
391
|
+
const profiles = RAIL_PROFILES.map(buildTreasuryDestinationProfile);
|
|
392
|
+
const configuredProfiles = profiles.filter((entry) => entry.configured);
|
|
393
|
+
const explicitProfiles = profiles.filter((entry) => entry.explicit_per_rail_configured);
|
|
394
|
+
const publicClaimableProfiles = profiles.filter((entry) => entry.public_claim_allowed);
|
|
395
|
+
const internalOnlyProfiles = profiles.filter((entry) => entry.compliance_posture === "internal_only_policy_gated");
|
|
396
|
+
return {
|
|
397
|
+
product: "xytara",
|
|
398
|
+
category: "machine-commerce-operator-treasury-destinations-pack",
|
|
399
|
+
pack_version: "xytara-operator-treasury-destinations-pack-v1",
|
|
400
|
+
posture: "operator_only_custody_visibility_and_per-rail_destination_readiness",
|
|
401
|
+
profiles,
|
|
402
|
+
readiness_summary: {
|
|
403
|
+
explicit_per_rail_configured_count: explicitProfiles.length,
|
|
404
|
+
configured_profile_count: configuredProfiles.length,
|
|
405
|
+
public_claimable_profile_count: publicClaimableProfiles.length,
|
|
406
|
+
readiness_only_profile_count: profiles.filter((entry) => !entry.public_claim_allowed && entry.compliance_posture !== "internal_only_policy_gated").length,
|
|
407
|
+
internal_only_profile_count: internalOnlyProfiles.length,
|
|
408
|
+
reporting_gap_count: profiles.filter((entry) => Array.isArray(entry.reporting_gap_fields) && entry.reporting_gap_fields.length > 0).length,
|
|
409
|
+
fallback_only_count: profiles.filter((entry) => entry.readiness_state === "fallback_only_not_explicitly_per-rail").length,
|
|
410
|
+
partially_configured_count: profiles.filter((entry) => entry.readiness_state === "partially_configured").length,
|
|
411
|
+
unconfigured_count: profiles.filter((entry) => entry.readiness_state === "unconfigured").length
|
|
412
|
+
},
|
|
413
|
+
public_claim_boundary: {
|
|
414
|
+
live_claimable_rails: publicClaimableProfiles.map((entry) => entry.rail_id),
|
|
415
|
+
readiness_only_rails: profiles
|
|
416
|
+
.filter((entry) => !entry.public_claim_allowed && entry.compliance_posture !== "internal_only_policy_gated")
|
|
417
|
+
.map((entry) => entry.rail_id),
|
|
418
|
+
internal_only_rails: internalOnlyProfiles.map((entry) => entry.rail_id),
|
|
419
|
+
rule: "only_rails_with_public_claim_allowed_true_should_be_described_as_live_landing_paths"
|
|
420
|
+
},
|
|
421
|
+
supported_surfaces: {
|
|
422
|
+
treasury_lane_ref: "/v1/treasury",
|
|
423
|
+
treasury_summary_ref_template: "/v1/economics/accounts/:account_id/treasury-summary",
|
|
424
|
+
treasury_signoff_pack_ref_template: "/v1/economics/accounts/:account_id/treasury-signoff-pack",
|
|
425
|
+
rail_summary_ref_template: "/v1/economics/accounts/:account_id/rail-summary",
|
|
426
|
+
rail_signoff_pack_ref_template: "/v1/economics/accounts/:account_id/rail-signoff-pack",
|
|
427
|
+
payment_setup_doc_ref: "REAL_PAYMENT_SETUP.md",
|
|
428
|
+
native_setup_doc_ref: "BSV_TERANODE_SETUP.md",
|
|
429
|
+
validation_preview_ref: "/v1/treasury-destinations/validate-preview"
|
|
430
|
+
},
|
|
431
|
+
operator_rule: configuredProfiles.length > 0
|
|
432
|
+
? "claim_only_the_rails_with_real_configured_destinations_as_live_landing_paths"
|
|
433
|
+
: "no_multi-rail_operational_claims_until_real_destinations_exist",
|
|
434
|
+
custody_visibility_rule: "do_not_expose_real_external_refs_or_custody_refs_on_public_surfaces",
|
|
435
|
+
config_examples: Object.fromEntries(RAIL_PROFILES.map((profile) => [profile.settlement_mode, profile.config_template]))
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function buildTreasuryDestinationsPack() {
|
|
440
|
+
const operatorPack = buildOperatorTreasuryDestinationsPack();
|
|
441
|
+
return {
|
|
442
|
+
product: "xytara",
|
|
443
|
+
category: "machine-commerce-treasury-destinations-pack",
|
|
444
|
+
pack_version: "xytara-treasury-destinations-pack-v3",
|
|
445
|
+
posture: "public_treasury_destination_readiness_without_custody_refs",
|
|
446
|
+
profiles: operatorPack.profiles.map(sanitizeTreasuryDestinationProfile),
|
|
447
|
+
readiness_summary: operatorPack.readiness_summary,
|
|
448
|
+
public_claim_boundary: operatorPack.public_claim_boundary,
|
|
449
|
+
supported_surfaces: {
|
|
450
|
+
treasury_lane_ref: "/v1/treasury",
|
|
451
|
+
treasury_summary_ref_template: "/v1/economics/accounts/:account_id/treasury-summary",
|
|
452
|
+
rail_summary_ref_template: "/v1/economics/accounts/:account_id/rail-summary",
|
|
453
|
+
payment_setup_doc_ref: "REAL_PAYMENT_SETUP.md",
|
|
454
|
+
native_setup_doc_ref: "BSV_TERANODE_SETUP.md",
|
|
455
|
+
validation_preview_ref: "/v1/treasury-destinations/validate-preview",
|
|
456
|
+
operator_pack_ref: "/v1/treasury-destinations/operator-pack"
|
|
457
|
+
},
|
|
458
|
+
operator_rule: operatorPack.operator_rule,
|
|
459
|
+
claim_discipline_rule: "unsupported_or_unconfigured_rails_may_be_listed_as_architecture_but_not_as_live_landing_paths",
|
|
460
|
+
privacy_rule: "public_surfaces_must_not_expose_real_treasury_landing_refs_or_custody_provider_refs",
|
|
461
|
+
config_examples: operatorPack.config_examples
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function summarizeTreasuryDestinationsPack() {
|
|
466
|
+
const pack = buildTreasuryDestinationsPack();
|
|
467
|
+
return {
|
|
468
|
+
product: "xytara",
|
|
469
|
+
category: "machine-commerce-treasury-destinations-pack-summary",
|
|
470
|
+
summary_version: "xytara-treasury-destinations-pack-summary-v2",
|
|
471
|
+
profile_count: pack.profiles.length,
|
|
472
|
+
configured_profile_count: pack.profiles.filter((entry) => entry.configured).length,
|
|
473
|
+
explicit_per_rail_configured_count: pack.readiness_summary.explicit_per_rail_configured_count,
|
|
474
|
+
public_claimable_profile_count: pack.readiness_summary.public_claimable_profile_count,
|
|
475
|
+
readiness_only_profile_count: pack.readiness_summary.readiness_only_profile_count,
|
|
476
|
+
reporting_gap_count: pack.readiness_summary.reporting_gap_count,
|
|
477
|
+
internal_only_profile_count: pack.profiles.filter((entry) => entry.compliance_posture === "internal_only_policy_gated").length,
|
|
478
|
+
public_claim_boundary: pack.public_claim_boundary,
|
|
479
|
+
linked_surfaces: pack.supported_surfaces
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function summarizeOperatorTreasuryDestinationsPack() {
|
|
484
|
+
const pack = buildOperatorTreasuryDestinationsPack();
|
|
485
|
+
return {
|
|
486
|
+
product: "xytara",
|
|
487
|
+
category: "machine-commerce-operator-treasury-destinations-pack-summary",
|
|
488
|
+
summary_version: "xytara-operator-treasury-destinations-pack-summary-v1",
|
|
489
|
+
profile_count: pack.profiles.length,
|
|
490
|
+
configured_profile_count: pack.readiness_summary.configured_profile_count,
|
|
491
|
+
explicit_per_rail_configured_count: pack.readiness_summary.explicit_per_rail_configured_count,
|
|
492
|
+
public_claimable_profile_count: pack.readiness_summary.public_claimable_profile_count,
|
|
493
|
+
readiness_only_profile_count: pack.readiness_summary.readiness_only_profile_count,
|
|
494
|
+
reporting_gap_count: pack.readiness_summary.reporting_gap_count,
|
|
495
|
+
internal_only_profile_count: pack.profiles.filter((entry) => entry.compliance_posture === "internal_only_policy_gated").length,
|
|
496
|
+
public_claim_boundary: pack.public_claim_boundary,
|
|
497
|
+
linked_surfaces: pack.supported_surfaces
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function buildTreasuryDestinationValidationPreview(input) {
|
|
502
|
+
const providedMap = input && typeof input === "object" && !Array.isArray(input)
|
|
503
|
+
? input.treasury_destinations_by_settlement_mode
|
|
504
|
+
: null;
|
|
505
|
+
const previousJson = process.env.XYTARA_TREASURY_DESTINATIONS_JSON;
|
|
506
|
+
const previousPath = process.env.XYTARA_TREASURY_DESTINATIONS_PATH;
|
|
507
|
+
try {
|
|
508
|
+
if (providedMap && typeof providedMap === "object") {
|
|
509
|
+
process.env.XYTARA_TREASURY_DESTINATIONS_JSON = JSON.stringify(providedMap);
|
|
510
|
+
delete process.env.XYTARA_TREASURY_DESTINATIONS_PATH;
|
|
511
|
+
}
|
|
512
|
+
const pack = buildTreasuryDestinationsPack();
|
|
513
|
+
return {
|
|
514
|
+
product: "xytara",
|
|
515
|
+
category: "machine-commerce-treasury-destination-validation-preview",
|
|
516
|
+
preview_version: "xytara-treasury-destination-validation-preview-v1",
|
|
517
|
+
operator_rule: pack.operator_rule,
|
|
518
|
+
readiness_summary: pack.readiness_summary,
|
|
519
|
+
profiles: pack.profiles.map((profile) => ({
|
|
520
|
+
rail_id: profile.rail_id,
|
|
521
|
+
readiness_state: profile.readiness_state,
|
|
522
|
+
public_claim_status: profile.public_claim_status,
|
|
523
|
+
public_claim_allowed: profile.public_claim_allowed,
|
|
524
|
+
explicit_per_rail_configured: profile.explicit_per_rail_configured,
|
|
525
|
+
missing_required_fields: profile.field_requirements.missing_required_fields,
|
|
526
|
+
missing_recommended_fields: profile.field_requirements.missing_recommended_fields
|
|
527
|
+
}))
|
|
528
|
+
};
|
|
529
|
+
} finally {
|
|
530
|
+
if (previousJson === undefined) delete process.env.XYTARA_TREASURY_DESTINATIONS_JSON;
|
|
531
|
+
else process.env.XYTARA_TREASURY_DESTINATIONS_JSON = previousJson;
|
|
532
|
+
if (previousPath === undefined) delete process.env.XYTARA_TREASURY_DESTINATIONS_PATH;
|
|
533
|
+
else process.env.XYTARA_TREASURY_DESTINATIONS_PATH = previousPath;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
module.exports = {
|
|
538
|
+
buildOperatorTreasuryDestinationsPack,
|
|
539
|
+
summarizeOperatorTreasuryDestinationsPack,
|
|
540
|
+
buildTreasuryDestinationsPack,
|
|
541
|
+
summarizeTreasuryDestinationsPack,
|
|
542
|
+
buildTreasuryDestinationValidationPreview
|
|
543
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { buildOperatorTreasuryDestinationsPack } = require("./treasury_destinations_contract");
|
|
4
|
+
|
|
5
|
+
const RAILS = [
|
|
6
|
+
"bsv_teranode",
|
|
7
|
+
"evm",
|
|
8
|
+
"base",
|
|
9
|
+
"usdc",
|
|
10
|
+
"dai",
|
|
11
|
+
"monero"
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
function buildRailPolicies() {
|
|
15
|
+
const operatorPack = buildOperatorTreasuryDestinationsPack();
|
|
16
|
+
const bySettlementMode = new Map(
|
|
17
|
+
(operatorPack.profiles || []).map((profile) => [profile.settlement_mode, profile])
|
|
18
|
+
);
|
|
19
|
+
return RAILS.map((settlementMode) => {
|
|
20
|
+
const profile = bySettlementMode.get(settlementMode) || null;
|
|
21
|
+
return {
|
|
22
|
+
settlement_mode: settlementMode,
|
|
23
|
+
destination_configured: Boolean(profile && profile.configured),
|
|
24
|
+
egress_posture: "manual_review_only",
|
|
25
|
+
autonomous_release_allowed: false,
|
|
26
|
+
manual_reason_required: true,
|
|
27
|
+
signoff_required: true,
|
|
28
|
+
outbound_default_state: "blocked",
|
|
29
|
+
policy_scope: profile && profile.compliance_posture ? profile.compliance_posture : null
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function buildTreasuryEgressPolicyPack() {
|
|
35
|
+
const railPolicies = buildRailPolicies();
|
|
36
|
+
return {
|
|
37
|
+
product: "xytara",
|
|
38
|
+
category: "machine-commerce-treasury-egress-policy-pack",
|
|
39
|
+
pack_version: "xytara-treasury-egress-policy-pack-v1",
|
|
40
|
+
posture: "black_hole_treasury_easy_inbound_manual_review_only_outbound",
|
|
41
|
+
autonomous_release_allowed: false,
|
|
42
|
+
operator_review_required: true,
|
|
43
|
+
manual_reason_required: true,
|
|
44
|
+
default_policy: {
|
|
45
|
+
inbound_posture: "open_to_configured_payment_and_settlement_paths",
|
|
46
|
+
outbound_posture: "blocked_until_manual_review_and_signoff",
|
|
47
|
+
autonomous_release_allowed: false,
|
|
48
|
+
operator_review_required: true,
|
|
49
|
+
manual_reason_required: true,
|
|
50
|
+
treasury_justification_required: true,
|
|
51
|
+
refund_signal_is_not_payout_authority: true,
|
|
52
|
+
dual_control_recommended: true
|
|
53
|
+
},
|
|
54
|
+
rail_policies: railPolicies,
|
|
55
|
+
control_points: [
|
|
56
|
+
"payment-ledger",
|
|
57
|
+
"reconciliation-report",
|
|
58
|
+
"treasury-signoff-pack",
|
|
59
|
+
"rail-signoff-pack",
|
|
60
|
+
"refund-review",
|
|
61
|
+
"market-signoff-pack"
|
|
62
|
+
],
|
|
63
|
+
linked_surfaces: {
|
|
64
|
+
treasury_destinations_operator_pack_ref: "/v1/treasury-destinations/operator-pack",
|
|
65
|
+
treasury_signoff_pack_ref_template: "/v1/economics/accounts/:account_id/treasury-signoff-pack",
|
|
66
|
+
rail_signoff_pack_ref_template: "/v1/economics/accounts/:account_id/rail-signoff-pack",
|
|
67
|
+
market_signoff_pack_ref: "/v1/economics/markets/signoff-pack",
|
|
68
|
+
payment_ledger_ref: "/v1/payment-ledger",
|
|
69
|
+
reconciliation_report_ref: "/v1/reconciliation-report"
|
|
70
|
+
},
|
|
71
|
+
operator_rule: "no_funds_leave_treasury_autonomously_without_clear_manual_reason_and_operator_review"
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function summarizeTreasuryEgressPolicyPack() {
|
|
76
|
+
const pack = buildTreasuryEgressPolicyPack();
|
|
77
|
+
return {
|
|
78
|
+
product: "xytara",
|
|
79
|
+
category: "machine-commerce-treasury-egress-policy-pack-summary",
|
|
80
|
+
summary_version: "xytara-treasury-egress-policy-pack-summary-v1",
|
|
81
|
+
rail_policy_count: pack.rail_policies.length,
|
|
82
|
+
configured_rail_count: pack.rail_policies.filter((entry) => entry.destination_configured).length,
|
|
83
|
+
autonomous_release_allowed: pack.default_policy.autonomous_release_allowed,
|
|
84
|
+
linked_surfaces: pack.linked_surfaces
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
module.exports = {
|
|
89
|
+
buildTreasuryEgressPolicyPack,
|
|
90
|
+
summarizeTreasuryEgressPolicyPack
|
|
91
|
+
};
|