Lacuna/Labs
sale-effectiveness-postmortem
light purple
#296 / 601

NAME

sale-effectiveness-postmortem — Post-sale narrative: lift, conversion change, fee impact, what to repeat.

SYNOPSIS

id sale-effectiveness-postmortem tier light-purple section §9. Light purple — cloud reasoning (51 baseline, 86 post-matrix) trigger event:sale-ended tools etsy/receipts, sakura/cloud-reason source new

DESCRIPTION

Calendar-aware. Reads the date, your past seasonal lift, current trends. Surfaces what worked last year with concrete inventory + caption suggestions.

Post-sale narrative: lift, conversion change, fee impact, what to repeat.

MECHANISM

PREfetchGUARDtier: light-purpleACTperformRESULTrenderON-ERRretry / esc
;;~ title    "Sale-effectiveness postmortem"
;;~ author   "lacuna"
;;~ version  1
;;~ mode     automation
;;~ flavor   light-purple
;;~ id       sale-effectiveness-postmortem
;;~ trigger  event:sale-ended
;;~ touches  ()
;;~ summary  "After a sale ends, write the postmortem: lift, conversion change, fee impact, what to repeat."

;; Fires when a sale ends. Pulls the receipts for the sale window +
;; the pre-sale baseline window of the same length. Sonnet writes the
;; postmortem narrative: what worked, what didn't, what to keep.

(cart 'sale-effectiveness-postmortem
  '((author    . "lacuna")
    (version   . 1)
    (read-only . #t)))

(define (start ctx)
  (let ((sale-id (ctx-get 'sale-id ctx)))
    (if (null? sale-id)
        (escalate 'missing-sale-id null)
        (next 'fetch ctx))))

(define (fetch ctx)
  (let ((sale-id (ctx-get 'sale-id ctx)))
    (act 'etsy/receipts (list 'sale-window sale-id) '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 'receipts r ctx))))))

(define (reason ctx)
  (let ((receipts (ctx-get 'receipts ctx)))
    (act 'sakura/cloud-reason
         (list 'task 'sale-postmortem receipts)
         '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 'postmortem r ctx))))))

(define (announce ctx) (done))

source: curator-web/src/scheme/carts/etsy/sale-effectiveness-postmortem.sks · 52 lines

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

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)