askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
dbbasic-package.json · 9.3 KB · 58 lines
| 1 | { |
| 2 | "id": "app-exchange", |
| 3 | "name": "Exchange", |
| 4 | "version": "0.6.0", |
| 5 | "description": "Box-to-box exchange of signed business documents, phase 0 (docs/box-to-box-exchange.md). A box is its domain: it publishes a signed profile at /.well-known/dbbasic (site_exchange_profile: company name, endpoint, Ed25519 public keys active and retired, accepted document types) and receives at POST /webhooks/exchange (webhook_exchange, the core raw-body route, so what is kept is the bytes that arrived). Trading partners are explicit and mutual: one owner asks, the other's owner accepts after checking that the request was signed with the key the requester's domain publishes, both pin each other's keys, either can disconnect and the next document is refused. A delivered document is checked in order (connected partner, pinned keys, both signatures, delivery stamp inside the clock window, addressed to us, well formed, a type this partner may send, a new (sender, id)), stored verbatim and frozen in exchange_inbox, and answered with a signed receipt; a resend stores nothing and gets the first receipt back. Sending (action_exchange_send) writes a signed envelope into exchange_outbox; the daemon's pass (system_exchange_deliver, every three minutes) delivers it with retries and backoff and keeps the partner's receipt once it verifies. The private key is a 0600 file outside every backup; cryptography is the optional `exchange` extra and without it everything here refuses, naming it. Operator actions (setup, key rotation, connect, accept, disconnect, document types per direction, requeue) are action_exchange_admin, for admins and the owner role. Email fallback is not built (phase 3). 0.2.0 turns documents into records, as a narrow partner principal (role exchange_partner, which the rules let create orders, order_lines, supplier_bills and supplier_bill_lines and nothing else): a purchase order becomes a draft sale order with its lines and stamped totals; an order confirmation is checked against the purchase order it answers and differences are shown, never applied; an invoice or credit note becomes a supplier bill (app-bills) in `received`, never paid by anything but a person, linked to our purchase order or to the bill it credits; a remittance waits as awaiting_confirmation until a person confirms it against the bank (action_exchange_confirm_remittance), which records the payment under the payments collection's own rules; a goods receipt is recorded against the order it answers. A document that cannot be mapped (a package not installed, a reference we do not know, totals that do not add up) stays in the inbox with the reason, counted as attention, and op=remap retries one that made no record. 0.2.1: sending a document and confirming a remittance are staff's (an admin, the owner role, role:manager), as invoice money and payments became staff's in app-invoices 0.15.0 and app-payments 0.8.0: a plain registered user is a customer who owns the orders and invoices checkout raises, and could otherwise send one in the business's name or record money received on their own bill. The execute grants moved from registered to the staff roles (the old ones retracted), and the objects check again: confirm asks the policy for create on every payment before writing any. A mapped purchase order is stamped reserves_stock=false: it is a back-office draft and holds nothing on the shelf. 0.3.0 (phase 1, from the two-company simulation): every priced line carries its unit as a UN/ECE Rec 20 code -- the line's unit_code, else its product's free-text unit coded (kg -> KGM, bags -> XBG), else C62 -- and a unit nobody can code is refused rather than sent as one; quantities may be decimal; received lines keep their unit on the order and the bill. Totals are made correct on send whether or not the totals handlers run: a record never totalled is stamped with what the handler would write, and one whose stored total disagrees with its lines is refused naming both numbers. 0.4.0: the partner principal may also create supplier_bill_credits, so a received credit note is applied as its document says in the act that records it (app-bills 0.3.0); a payment is remitted from supplier_payments, stating what was paid on each bill, and a credit note sent is applied at the sender (invoice_credits). A confirmation is made and compared line by line: each line names the buyer's line it answers (ref_line_id) and says accepted, changed, rejected (sent with quantity 0) or added; the response is derived from the lines, and a seller who calls a changed order accepted is refused. The buyer's box lists every difference (quantity, unit, unit price, rejected, added) as attention, and action_exchange_resolve (staff) accepts it -- the purchase order is changed to match through writes recorded under that person's name, totals restamped -- or rejects it; the inbox row records who decided what and when (resolution, resolved_by, resolved_at). 0.5.0: notices. Disconnecting sends a signed connection_end; the other box records the partner disconnected by them, with the reason (trading_partners v2), and stops sending. A document refused after its sender was proven (a type not taken, malformed, an id reused, addressed elsewhere) is answered with a signed refusal receipt; a person can refuse any received document later (action_exchange_resolve decision refuse, with a reason), which sends a signed document_refusal and disputes a bill made from a refused invoice. The sender verifies either, keeps it on the outbox row (status refused, exchange_outbox v2; attention exchange_refused) and stamps the record the document was made from (exchange_status: Refused by <partner>: <reason>). Strangers still get one unsigned not_a_partner. 0.6.0: action_exchange_admin op=check says what this box needs to trade, each with its fix in plain words -- the trading name, the signing key and where the operator says its backup is (op=record_key_backup; exchange_keys v2), the daemon and the scheduler extra, the totals reactions, who holds the owner and manager roles, partners waiting, packages missing -- and changes nothing. A record that does not make a well-formed document is refused with what is wrong instead of failing the request.", |
| 6 | "compatibility": {"dbbasic_object_server": ">=0.1.0"}, |
| 7 | "dependencies": ["app-views", "app-nav"], |
| 8 | "objects": [ |
| 9 | {"id": "site_exchange_profile", "path": "objects/site/exchange_profile.py"}, |
| 10 | {"id": "webhook_exchange", "path": "objects/webhook/exchange.py"}, |
| 11 | {"id": "action_exchange_admin", "path": "objects/action/exchange_admin.py"}, |
| 12 | {"id": "action_exchange_send", "path": "objects/action/exchange_send.py"}, |
| 13 | {"id": "action_exchange_confirm_remittance", "path": "objects/action/exchange_confirm_remittance.py"}, |
| 14 | {"id": "action_exchange_resolve", "path": "objects/action/exchange_resolve.py"}, |
| 15 | {"id": "system_exchange_deliver", "path": "objects/system/exchange_deliver.py"} |
| 16 | ], |
| 17 | "schemas": [ |
| 18 | {"collection": "exchange_identity", "path": "schemas/exchange_identity.json"}, |
| 19 | {"collection": "exchange_keys", "path": "schemas/exchange_keys.json"}, |
| 20 | {"collection": "trading_partners", "path": "schemas/trading_partners.json"}, |
| 21 | {"collection": "exchange_inbox", "path": "schemas/exchange_inbox.json"}, |
| 22 | {"collection": "exchange_outbox", "path": "schemas/exchange_outbox.json"} |
| 23 | ], |
| 24 | "permissions": [{"path": "permissions/rules.json"}], |
| 25 | "seed": [ |
| 26 | {"collection": "views", "path": "seed/views.tsv"}, |
| 27 | {"collection": "site_routes", "path": "seed/site_routes.tsv"} |
| 28 | ], |
| 29 | "migrations": [], |
| 30 | "schedules": [ |
| 31 | {"id": "exchange_deliver", "object_id": "system_exchange_deliver", "schedule": "*/3 * * * *", |
| 32 | "description": "Deliver every queued exchange document whose next attempt has come, with a freshly signed delivery stamp; keep the partner's receipt once it verifies, stop on a refusal, back off (1 minute doubling to 6 hours, 12 attempts) when the partner does not answer. Safe to retry: the receiver stores a document once by its id."} |
| 33 | ], |
| 34 | "nav": [ |
| 35 | {"id": "exchange", "label": "Exchange", "path": "/exchange", |
| 36 | "blurb": "Documents sent to and received from trading partners' boxes", |
| 37 | "surface": "member", "group": "Commerce", "order": 290} |
| 38 | ], |
| 39 | "attention": [ |
| 40 | {"id": "partners_to_accept", "collection": "trading_partners", "where": {"status": "pending"}, |
| 41 | "label": "Partners asking to connect", "path": "/exchange", "nav_id": "exchange", |
| 42 | "group": "Commerce", "severity": "normal"}, |
| 43 | {"id": "exchange_needs_attention", "collection": "exchange_inbox", |
| 44 | "where": {"mapping_status": "needs_attention"}, |
| 45 | "label": "Received documents to look at", "path": "/exchange", "nav_id": "exchange", |
| 46 | "group": "Commerce", "severity": "normal"}, |
| 47 | {"id": "remittances_to_confirm", "collection": "exchange_inbox", |
| 48 | "where": {"mapping_status": "awaiting_confirmation"}, |
| 49 | "label": "Remittances to confirm against the bank", "path": "/exchange", "nav_id": "exchange", |
| 50 | "group": "Money", "severity": "normal"}, |
| 51 | {"id": "exchange_refused", "collection": "exchange_outbox", "where": {"status": "refused"}, |
| 52 | "label": "Documents a partner refused", "path": "/exchange", "nav_id": "exchange", |
| 53 | "group": "Commerce", "severity": "warning"}, |
| 54 | {"id": "exchange_undelivered", "collection": "exchange_outbox", "where": {"status": "dead"}, |
| 55 | "label": "Documents not delivered", "path": "/exchange", "nav_id": "exchange", |
| 56 | "group": "Commerce", "severity": "normal"} |
| 57 | ] |
| 58 | } |