commerce: line-level discount attribution (16 tests) — Phase 5 ext
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m5s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m5s
attribution.sx — the briefing's marquee "which line item triggered this discount?" backward query. promo-lines gives each promo's pure scope (percent/member -> class lines, bundle -> sku lines, fixed -> order-level); promo-toucheso relates (code, line) for applying promos, run forward (lines-for-code) and backward (codes-for-line). Additive; promo amounts unchanged. Total 201/201 across 12 suites. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,7 @@ reconciliation — all auditable via the event log.
|
||||
|
||||
## Status (rolling)
|
||||
|
||||
`bash lib/commerce/conformance.sh` → **185/185** (11 suites: catalog, cart, price, api, promo, stack, quote, ledger, order, recon, federation) — **Phases 1-4 done (roadmap complete)**
|
||||
`bash lib/commerce/conformance.sh` → **201/201** (12 suites; + attribution) — **roadmap complete; Phase 5 extensions in progress**
|
||||
|
||||
## Ground rules
|
||||
|
||||
@@ -78,9 +78,9 @@ lib/commerce/api.sx ── (commerce/add) (commerce/total) (commerce/checkout)
|
||||
## Phase 5 — Extensions (backlog; base roadmap complete)
|
||||
Thesis-aligned deepenings of the relational/composition showcase. Pick the one
|
||||
that unlocks the most tests per effort each iteration.
|
||||
- [ ] line-level discount attribution — "which line item triggered this discount?"
|
||||
as a backward miniKanren query (briefing gotcha; promos currently apply at
|
||||
class level). Refactor promo amounts to also yield per-line attribution.
|
||||
- [x] line-level discount attribution — "which line item triggered this discount?"
|
||||
as a backward miniKanren query (`attribution.sx`: `promo-toucheso` relation,
|
||||
`lines-for-code`/`codes-for-line` both directions, `order-level-codes` for fixed).
|
||||
- [ ] time-windowed promotions — promos gated by a validity window; quote takes a
|
||||
datetime, determinism preserved. (quote.sx already documents datetime intent.)
|
||||
- [ ] discount-aware tax policy — alternative `cart-quote` computing tax on the
|
||||
@@ -97,6 +97,14 @@ that unlocks the most tests per effort each iteration.
|
||||
Keeps lib/commerce provider-agnostic; enables multi-provider support in the core.
|
||||
|
||||
## Progress log
|
||||
- 2026-06-07 — `attribution.sx` (Phase 5 ext): line-level discount attribution —
|
||||
the briefing's marquee "which line item triggered this discount?" query.
|
||||
`promo-lines` is the pure per-promo scope (percent/member → class lines, bundle
|
||||
→ sku lines, fixed → order-level/none); `promo-toucheso` relates (code, line)
|
||||
for applying promos, run forward (`lines-for-code`) and backward
|
||||
(`codes-for-line`). `order-level-codes` lists applying fixed promos; predicate
|
||||
`line-touched-by?`. Additive — promo.sx amounts unchanged. attribution suite
|
||||
16/16; total 201/201 (12 suites).
|
||||
- 2026-06-07 — `recon.sx` + `federation.sx` (**Phase 4 complete — roadmap done**).
|
||||
`recon.sx`: reconciliation as relational queries over the ledger. Per-order
|
||||
summary tuples (id total paid refunded net status); `recon-statuso`/`neto`/
|
||||
|
||||
Reference in New Issue
Block a user