Repository navigation
feat(payments): add governed collections and disbursements - #2658
Conversation
8ede031 to
33dabfb
Compare
4da0fd9 to
58040ed
Compare
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…cess Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Main moved pkcs1 to 0.8, whose owned RsaPublicKey is generic over its integer type. Borrow the modulus through RsaPublicKeyRef, as registry-evidencectl does. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…he simulator Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…ules Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
A request whose payer has a configured outcome stayed pending until the worker advanced it, so a fast click on the hosted page could decide it first. The rule now settles the request when it is created. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Main moved Adapter and Coordinator product prose out of products/ and into the docs site. Carry the payment contracts this branch had written into the removed CONCEPT, DEPLOYMENT, PRODUCT-CONTRACT and SECURITY-MODEL files to their site pages: typed payment hosting on the Adapter configure page, the payments connection on the Coordinator configuration reference, the six payment operations and their completions on the Coordinator configure page, payment recovery on the operate page, and the payment invariant (now COORDINATOR-INV-16, since main assigned INV-15) with its operator obligation on the security page. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The payment provider pack schema still carried references to the removed Adapter concept document; regenerate it and the identifier catalogue digests from their sources. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Collections are simulation-only, as the payment-collections contract states. A collection binding is accepted only with the simulator provider and simulation: true; a Mifos or mapped HTTP collection, or a simulator binding with simulation: false, is refused with adapter.payment.collection-simulation-only by both adapter serve and adapterctl payments check. The generated payments schema fixes simulation to true. The Mifos and HTTP collection branches in the router and request path stay for a follow-up; no new connection can reach them. Service and authoring tests that ran live collections now assert the refusal, and the provider-pack pin tests use pinned simulator collections. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
…ction The simulator reports a cancel on its hosted page, or a cancelled payer rule, as RJC/FAILED with failureReason payer-cancelled. The connector refused that pairing as a protocol error, holding the collection. Map it to CollectionState::Failed like payer-rejected. The tests use a status body captured from the simulator for a cancelled payer rule, decoded directly and through SimulatorClient. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Startup checks the adapter_g2p tables when disbursements are configured; the payment example listed only the collection grants. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The mifos-payment-hub pack is not in this repository or published yet. Say the operator supplies a reviewed pack matching the pin, and show --payment-provider-pack on adapter serve in the example and on the Adapter configure page. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Only the collection example runs against the simulator. The disbursement example is checked and tested with coordinatorctl scenarios; no simulator pack or Adapter example backs its connection. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The changelog and example limits read as if no live provider ships. Add the disbursement entry (operations, provider packs, --payment-provider-pack, bearer and mifos-legacy-signature authentication), say live collection providers where collections are meant, and state that live Mifos signing through a real Transit engine is unverified, so a live disbursement must not move real money until that follow-up lands. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Starting the same workflow again with the same bill or instruction identity reattaches to the version's existing attempt, and record-receipt returns a receipt already recorded. A declined, cancelled or expired collection, or a failed disbursement, keeps the version bound to its attempt; a new version is the way to try again. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
retry-same on a held payments.request-disbursement/v1 told the operator to inspect or cancel, although the operation offers a read-only original-request lookup. When the operation supports a read receipt, the refusal now names reconcile; unkeyed mutations and evaluations keep their advice. The mutation-uncertain problem detail covers both cases. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The collection and disbursement request and request-receipt handlers audited a successful release with no attempt, stored as the nil UUID. Pass the accepted collection or disbursement id; refusals still carry none. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
List the four disbursement routes in the payment contract. Say the simulator upgrades v1 and v2 state to v3, and that its hosted page is a standalone aid the Adapter and Coordinator do not reach yet. Add one set-up paragraph to the Adapter configure page: Transit custody (a non-exportable service-created signer, an imported public verifier), the Payment Hub EE channel and operations apps shipping with authorisation off, and draining Bound attempts before raising min_encryption_version. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
The service-issuer profile could read the payer identity, payer financial address, payment attempt, provider binding and reference, and digests. Issuance guards only the bill identity, tariff, amount, currency, simulation flag, payment state and receipt identifier; keep those and the issuance identifier. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Carry the simulation-only payments schema digest and the revised mutation-uncertain problem detail. Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
e67ddf2 to
ca05ea8
Compare
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Signed-off-by: Jeremi Joslin <jeremi@joslin.fr>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e46e149af
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| || observation.money.minor_units != self.provider_intent.money.minor_units | ||
| || observation.money.currency != self.provider_intent.money.currency | ||
| || observation.money.scale != self.provider_intent.money.scale | ||
| || !text(&observation.provider_reference, 512) |
There was a problem hiding this comment.
Enforce the public reference bound before retaining confirmation
If a provider mapping returns a confirmed observation with a 129–512-byte reference, this check accepts it and record_observation persists the attempt as terminal ProviderConfirmed. However, DisbursementStatus::validate limits provider references to 128 bytes, so the HTTP status conversion subsequently returns adapter.payment.unavailable. Later status requests skip provider observation for terminal attempts, leaving this disbursement permanently unreadable through the API; the supplied BReg reporting contract also limits the reference to 128 characters. Enforce the downstream bound before persisting the terminal observation so an invalid mapped reference cannot strand the attempt.
Useful? React with 👍 / 👎.
|
|
||
| fn canonical_registry_origin(value: &str) -> Result<String, G2pError> { | ||
| url::Url::parse(value) | ||
| .map(|url| url.origin().ascii_serialization()) |
There was a problem hiding this comment.
Preserve the registry deployment prefix in its source namespace
When two independent BReg deployments are exposed under different prefixes on the same HTTPS origin, such as /registry-a/ and /registry-b/, this normalization gives them the same source namespace whenever their record route and type match. The BReg client preserves those prefixes when making requests, so these are distinct authoritative sources. If they contain the same instruction UUID/version, find_instruction or the unique constraints in G2pStore::reserve treat the second deployment's instruction as an existing attempt and reject its disbursement with a conflict. Include the normalized deployment prefix in the namespace while continuing to ignore credential and access-profile rotation.
Useful? React with 👍 / 👎.
Coordinator workflows use dedicated typed steps to request a payment collection or a disbursement, wait for its named completion, and record the verified outcome. The optional Adapter payment host shares the Adapter listener and PostgreSQL infrastructure. Operator-owned connections set the tenant, biller, provider endpoints, credentials, currency policy, restricted BReg Actions and exact provider-pack pins.
What this adds
payment-fee-issuanceexample project holds the authoritative fee bill, a restricted Action that binds one payment attempt to an exact bill version, a restrictedrecord-payment-receiptAction, and a guard that issues the paid service once and only after a confirmed receipt. Theg2p-disbursementproject holds approved disbursement instructions and the restricted provider-confirmation report.adapter serve --payments-configmounts typed collection, disbursement, observation and reporting operations outside the generic record routes. It reserves one attempt per bill or instruction version before provider dispatch, retains the original binding, key and request bytes, and recovers lost acknowledgements from the saved command or exact readback.adapterctl payments checkandadapterctl payments contractvalidate connections offline and export the typed HTTP contract.payments.request-collection/v1,payments.read-collection/v1,payments.record-receipt/v1,payments.request-disbursement/v1,payments.read-disbursement/v1andpayments.record-provider-confirmation/v1over apaymentsconnection, with the host-ownedcollectionanddisbursementcompletions. An uncertain disbursement stays held and reconciles only through the read-only original-request lookup.payer-cancelledoutcome, and per-payer outcome rules that settle at request creation.Rebase onto current main
This branch was rebased onto
main(previously 134 commits behind) and the hosted-page simulator commits were added on top.products/adapter/CONCEPT.mdand the CoordinatorDEPLOYMENT.md,PRODUCT-CONTRACT.mdandSECURITY-MODEL.mdnow live on the site pages: typed payment hosting on Configure an Adapter project, thepaymentsconnection on the Coordinator configuration reference, the payment operations on the Coordinator configure page, payment recovery on the operate page, and the security invariant on the Coordinator security model.COORDINATOR-INV-15to the connection assertion audience, so the payment invariant is now COORDINATOR-INV-16, with operator obligation 14.pkcs1to 0.8. The Transit RSA key check now borrows the modulus throughRsaPublicKeyRef, asregistry-evidencectlalready does.Review notes (security-sensitive)
This change adds authorization and audit surface: restricted BReg Actions held by the Adapter reporter identity, Coordinator payment connections that carry no BReg grant, value-free payment audit events committed before effects, and durable payment attempts with no automatic expiry. The Coordinator security model page records the new invariant and operator obligation.
Verification
Local, on the rebased head:
cargo fmt --all --checkandcargo clippy --all-targets -- -D warningsover the Adapter, payment, Coordinator, BReg,registry-platform-crypto,registry-cli-docsandregistry-language-servercrates.cargo testover the same crates: 5,874 passed. 56 tests inregistry-bregctlandregistry-coordinatorfailed only because the local checkout sits under a group-writable parent directory, which the runtime-configuration permission check correctly refuses (platform.runtime-config.unsafe-file). CI runs them in a normal checkout.bregctl checkforpayment-fee-issuanceandg2p-disbursement(0 errors). Thepayment-fee-issuancenative acceptance helper rancheck, thebregctl testjourney suite,package,plan,apply,statusand the authorization probes against a disposable TLS PostgreSQL; theexact-fee-before-issuancejourney passed.uv run pytest, andpayment-simulator openapi --checkis clean.Not verified
record-receiptoperation stays withheld: Mifos Operations completion is a provider report and does not authorize a paid fee-bill receipt.simulation: true; no live collection provider is supported yet.g2p-disbursementBReg journeys were not run against PostgreSQL locally; onlybregctl checkran.