Lacuna/Labs
review-sentiment-tracker
light purple
#293 / 601

NAME

review-sentiment-tracker — Two-step: local sentiment first; only negative reviews escalate to cloud reasoning for theme analysis.

SYNOPSIS

id review-sentiment-tracker tier light-purple section §9. Light purple — cloud reasoning (51 baseline, 86 post-matrix) trigger event:new-review tools etsy/reviews, sakura/decide, sakura/cloud-reason source new

DESCRIPTION

Cheap local classifier reads the tone first. Only the genuinely negative messages escalate to cloud reasoning for deeper read. Saves API spend on the everyday-friendly stuff.

Two-step: local sentiment first; only negative reviews escalate to cloud reasoning for theme analysis.

MECHANISM

PREfetchGUARDtier: light-purpleACTperformRESULTrenderON-ERRretry / esc
;;~ title    "Review sentiment tracker"
;;~ author   "lacuna"
;;~ version  1
;;~ mode     automation
;;~ flavor   light-purple
;;~ id       review-sentiment-tracker
;;~ trigger  event:new-review
;;~ touches  ()
;;~ summary  "On a new review, score sentiment and surface the theme (shipping, fit, quality, communication)."

;; Two-step: local sentiment classification first (cheap, fast). If
;; the review is below 4 stars OR sentiment is negative, escalate the
;; theme analysis to Sonnet so the operator sees the why, not just
;; the what.

(cart 'review-sentiment-tracker
  '((author    . "lacuna")
    (version   . 1)
    (read-only . #t)))

(define (start ctx)
  (let ((review (ctx-get 'review ctx)))
    (if (null? review)
        (escalate 'missing-review null)
        (next 'classify ctx))))

(define (classify ctx)
  (let ((review (ctx-get 'review ctx)))
    (act 'sakura/decide
         (list 'task 'classify-review-sentiment review)
         'check-classify)))

(define (check-classify ctx)
  (let ((r (ctx-result ctx)))
    (cond
      ((null? r)              (escalate 'sakura-empty null))
      ((eq? r 'positive)      (next 'announce (ctx-set 'sentiment r ctx)))
      ((eq? r 'neutral)       (next 'announce (ctx-set 'sentiment r ctx)))
      ((eq? r 'negative)      (next 'theme (ctx-set 'sentiment r ctx)))
      (else                   (escalate 'sakura-garbled null)))))

(define (theme ctx)
  (let ((review (ctx-get 'review ctx)))
    (act 'sakura/cloud-reason
         (list 'task 'review-theme-analysis review)
         'check-theme)))

(define (check-theme 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 'theme r ctx))))))

(define (announce ctx) (done))

source: curator-web/src/scheme/carts/etsy/review-sentiment-tracker.sks · 57 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)