shipping-cost-optimization
light purple
#295 / 601
NAME
shipping-cost-optimization — Compare paid-vs-charged shipping across 90d, propose template edits with expected per-order delta.
SYNOPSIS
id shipping-cost-optimization
tier light-purple
section §9. Light purple — cloud reasoning (51 baseline, 86 post-matrix)
trigger analysis-pattern
tools etsy/ledger, sakura/cloud-reason
source new
DESCRIPTION
Looks at the buyer's ZIP, distance to operator, your past delivery history, carrier rate tables. Suggests the carrier + transit estimate that matches the real data.
Compare paid-vs-charged shipping across 90d, propose template edits with expected per-order delta.
MECHANISM
;;~ title "Shipping cost optimization" ;;~ author "lacuna" ;;~ version 1 ;;~ mode automation ;;~ flavor light-purple ;;~ id shipping-cost-optimization ;;~ trigger analysis-pattern ;;~ touches () ;;~ summary "Compare actual shipping cost paid vs charged across recent orders, propose template changes." ;; Fetch shipping events from the ledger for the last 90 days. Reason ;; over per-template paid-vs-charged delta. Sonnet proposes the ;; template edits with rationale + expected per-order delta. (cart 'shipping-cost-optimization '((author . "lacuna") (version . 1) (read-only . #t))) (define (start ctx) (let ((connected (ctx-get 'shop-connected ctx))) (cond ((not connected) (escalate 'shop-not-connected null)) (else (next 'fetch ctx))))) (define (fetch ctx) (act 'etsy/ledger (list 'shipping '90d) 'check-fetch)) (define (check-fetch ctx) (let ((r (ctx-result ctx))) (cond ((null? r) (escalate 'no-data null)) ((eq? r 'rate-limited) (after 30 'fetch ctx)) (else (next 'reason (ctx-set 'shipping-rows r ctx)))))) (define (reason ctx) (let ((rows (ctx-get 'shipping-rows ctx))) (act 'sakura/cloud-reason (list 'task 'shipping-cost-optimization rows) 'check-reason))) (define (check-reason ctx) (let ((r (ctx-result ctx))) (cond ((null? r) (escalate 'cloud-empty null)) ((not (string? r)) (escalate 'cloud-garbled null)) ((eq? r 'cloud-quota-exhausted) (escalate 'cloud-quota null)) ((eq? r 'cloud-consent-required) (escalate 'cloud-consent null)) (else (next 'announce (ctx-set 'plan r ctx)))))) (define (announce ctx) (done))
EXAMPLES
Example forthcoming —
docs/automations/examples.json entry editable in place.TIER
light purple
cloud reasoning · cents per call
FITNESS
Almost there
Works on smaller shops too; the answer sharpens as you collect more sales.
SEE ALSO
- voice-faithful-rewrite
- translate-listing-faithful
- brand-story-revise
- listing-tone-shift
- product-line-naming
- descriptive-rewrite-multiparagraph
- seo-title-rewrite
- listing-summary-marketing
- etsy-tagline-shop
- write-customer-recovery-message
- draft-customer-message-polished
- draft-refund-message
- draft-shipping-delay-note
- draft-custom-order-quote
- draft-policy-explanation-to-buyer
- draft-thank-you-warm
- draft-vacation-message
- draft-restock-announcement
HISTORY
canonical source: curator/docs/AUTOMATIONS-CANONICAL.md · §9-light-purple-cloud-reasoning-51-baseline-86-post-matrix
last regenerated: 2026-06-05 20:31 UTC (mechanical — edits land in the MD or sidecars, not here)
KNOWN BUGS
(none recorded — flag in AUTOMATIONS-CANONICAL.md or open an issue against the cart file)