Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
recon.sx — reconciliation as relational queries over the ledger: per-order summary tuples + recon-statuso/neto/mismatcho miniKanren relations, so overpaid/underpaid/settled and "settled to net N" are backward run* queries. Tests cover double-charge guard, partial refund, webhook replay. federation.sx (out-of-scope stub) — a federated catalog is the union of each instance's product facts, so the same relations query cross-instance (instances-with-sku, sku-offers, cheapest-offer). In-process mock, no network. Completes the commerce-on-sx roadmap (Phases 1-4). Total 185/185 across 11 suites. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
89 lines
1.8 KiB
Plaintext
89 lines
1.8 KiB
Plaintext
;; lib/commerce/tests/federation.sx — federated catalog (out-of-scope stub).
|
|
;; Uses (commerce-test name got expected) provided by conformance.sh.
|
|
|
|
(define
|
|
cat-a
|
|
(make-catalog
|
|
(list
|
|
(list "widget" 1000 :standard)
|
|
(list "book" 800 :zero-rated))
|
|
(list)
|
|
(list)))
|
|
|
|
(define
|
|
cat-b
|
|
(make-catalog
|
|
(list
|
|
(list "widget" 900 :standard)
|
|
(list "tea" 1200 :reduced))
|
|
(list)
|
|
(list)))
|
|
|
|
(define
|
|
cat-c
|
|
(make-catalog (list (list "widget" 1100 :standard)) (list) (list)))
|
|
|
|
(define
|
|
fed
|
|
(federation-add
|
|
(federation-add (make-federation :alpha cat-a) :beta cat-b)
|
|
:gamma cat-c))
|
|
|
|
;; --- structure ---
|
|
|
|
(commerce-test "is-stub" federation-stub? true)
|
|
(commerce-test
|
|
"instances"
|
|
(federation-instances fed)
|
|
(list :alpha :beta :gamma))
|
|
(commerce-test "product-count" (len (fed-products fed)) 5)
|
|
|
|
;; --- forward query ---
|
|
|
|
(commerce-test
|
|
"price-at-instance"
|
|
(run* p (fed-priceo fed :beta "widget" p))
|
|
(list 900))
|
|
|
|
;; --- backward queries (the showcase) ---
|
|
|
|
(commerce-test
|
|
"instances-with-widget"
|
|
(instances-with-sku fed "widget")
|
|
(list :alpha :beta :gamma))
|
|
|
|
(commerce-test
|
|
"instances-with-book"
|
|
(instances-with-sku fed "book")
|
|
(list :alpha))
|
|
|
|
(commerce-test
|
|
"instances-with-tea"
|
|
(instances-with-sku fed "tea")
|
|
(list :beta))
|
|
|
|
(commerce-test
|
|
"instance-by-price-backward"
|
|
(run* inst (fresh (c) (fed-producto fed inst "widget" 1100 c)))
|
|
(list :gamma))
|
|
|
|
;; --- offers + cheapest (deterministic selection) ---
|
|
|
|
(commerce-test
|
|
"widget-offers"
|
|
(sku-offers fed "widget")
|
|
(list
|
|
(list 1000 :alpha)
|
|
(list 900 :beta)
|
|
(list 1100 :gamma)))
|
|
|
|
(commerce-test
|
|
"cheapest-widget"
|
|
(cheapest-offer fed "widget")
|
|
(list 900 :beta))
|
|
(commerce-test
|
|
"cheapest-book"
|
|
(cheapest-offer fed "book")
|
|
(list 800 :alpha))
|
|
(commerce-test "cheapest-missing" (cheapest-offer fed "ghost") nil)
|