Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
b3f8d67
feat: spend a loopkit reward at qkit checkout for a single-use code
cljiahao Dec 1, 2026
34cd207
fix: list rewards on /c and let a spent reward show its qkit code again
cljiahao Dec 1, 2026
759954a
fix: expire qkit reward code with the voucher and tighten value valid…
cljiahao Dec 1, 2026
e6657c9
Merge remote-tracking branch 'origin/staging' into feat/qkit-reward-code
cljiahao Dec 1, 2026
9816d3f
chore: renumber qkit reward code migration to 0073
cljiahao Dec 1, 2026
7983581
Merge remote-tracking branch 'origin/staging' into feat/qkit-reward-code
cljiahao Dec 1, 2026
9d82bf1
Merge remote-tracking branch 'origin/staging' into feat/qkit-reward-code
cljiahao Dec 1, 2026
cae4806
docs: update folder READMEs for the qkit reward code change
cljiahao Dec 1, 2026
04e1157
fix: reject a qkit reward code kind without a value and make the pgTA…
cljiahao Dec 1, 2026
cd3bdd4
ci: skip type-only db-types in the mutation job
cljiahao Dec 1, 2026
15c7012
Merge remote-tracking branch 'origin/staging' into feat/qkit-reward-code
cljiahao Dec 1, 2026
63f94fb
chore: regenerate harness manifest for mutation filter
cljiahao Dec 2, 2026
0d3e35e
docs: note the mutation filter and manifest regen in folder READMEs
cljiahao Dec 2, 2026
3f145d8
fix: Stamp card default program, plan page account link, legacy start…
cljiahao Dec 2, 2026
f51dc87
Merge origin/staging into feat/qkit-reward-code, renumber migration t…
cljiahao Dec 2, 2026
395e3e9
Merge pull request #292 from merqo-io/feat/qkit-reward-code
cljiahao Dec 2, 2026
8e11174
test(e2e): cover the core stamp card flow (#296)
cljiahao Dec 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ against.
- `comment-hygiene-patterns.txt` — the canonical change-narration/ticket-reference pattern list, read at runtime by `hooks/post-edit-comment-check.sh`, `.husky/lib/comment-hygiene.sh`, and `.github/workflows/ci.yml`'s `comment-hygiene` job instead of each hardcoding its own copy; first 10 lines are anchored keyword patterns (feed all three surfaces), last 3 (date/ticket/issue reference) are lower-precision and feed only the two warn-only surfaces, not the CI hard gate
- `harness.json` — harness manifest (its `review_note` points at `docs/meta/templatecentral-adoption-log.md`, and the `AGENTS.md` `origin_hash` tracks the slimmed file; the hook-by-hook reference is `docs/meta/ai-harness-reference.md`): templateCentral version/stack/adaptation metadata, plus `seeded_files` — the enforcement-layer file list (path + sha256 `origin_hash`) that `verify-harness.sh` diffs against
- `hooks/`
- `regen-harness.sh` — human-run-only: rewrites every `origin_hash` in `harness.json` to match current on-disk content, blessing an intentional harness edit; `protect-files.sh` requires human approval before an agent can even edit it (most recently re-run 2026-11-10 after the AGENTS.md skills-table edit)
- `regen-harness.sh` — human-run-only: rewrites every `origin_hash` in `harness.json` to match current on-disk content, blessing an intentional harness edit; `protect-files.sh` requires human approval before an agent can even edit it (most recently re-run 2026-12-02 after the `ci.yml` mutation-filter edit)
- `settings.json` — wires each script in `hooks/` to a Claude Code lifecycle event (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, UserPromptSubmit) and sets tool `permissions` (allow/deny) and skill overrides
- `skills/`
- `verify-harness.sh` — harness integrity sensor: computes sha256 from committed HEAD blobs for every seeded file matched by a path guard (`hooks/`, `settings.json`, harness verifier/regen scripts, `.husky/`, `.gitleaks.toml`, `.github/workflows/`) and compares to `harness.json`'s `origin_hash` baseline; read-only, exits non-zero on drift; run by `.github/workflows/ci.yml` and husky's `pre-push` hook
Expand Down
4 changes: 2 additions & 2 deletions .claude/harness.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"richReadme": true,
"seeded_files": {
"AGENTS.md": {
"origin_hash": "eb921107a858d512b9778f925bbd3a47c71a04bb569d807f10b38417037f955c",
"origin_hash": "0ff7c4173834e166903ea2434408c1660c22a8f9371604d0ba6f91c3eaf61b78",
"path": "AGENTS.md"
},
".claude/settings.json": {
Expand Down Expand Up @@ -100,7 +100,7 @@
"path": ".gitleaks.toml"
},
".github/workflows/ci.yml": {
"origin_hash": "c84a211fb37ec23cbe9d83c37c80971f722de3c1d7151b388838ca15537517ed",
"origin_hash": "bb626e231a4a872300a034bef0ac9524a35b4eedf190756385f74712a560225e",
"path": ".github/workflows/ci.yml"
},
".claude/verify-harness.sh": {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ security scanning.

## Contents

- `ci.yml` — main CI pipeline, four jobs plus three PR-only gates: harness integrity (`.claude/verify-harness.sh`), `pnpm check`/`pnpm exec vitest --run --coverage`/coverage with an 80% changed-line gate (`diff-cover`); a separate `next build` job with dummy Supabase env vars; a Playwright e2e smoke job; a CHANGELOG-required-for-`src/`-changes gate (`skip-changelog` label bypasses); a README-freshness gate requiring every changed folder's `README.md` also be in the diff (`skip-readme-check` label bypasses) — the CI-time counterpart to `.husky/lib/readme-coupling.sh`'s commit-time nudge; a comment-hygiene gate scanning only the PR's added lines (`git diff -U0`) for change-narration comments, using the first 10 (hard-precision) lines of `.claude/comment-hygiene-patterns.txt` (`skip-comment-check` label bypasses) — the CI-time hard gate counterpart to `.husky/lib/comment-hygiene.sh`'s commit-time warn-only nudge and `.claude/hooks/post-edit-comment-check.sh`'s live edit-time nudge, both of which scan the full 13-line pattern file. Also a `db` job (migrations + pgTAP RLS) and a PR-only, advisory `mutation` job that Stryker-mutates whichever `src/lib/*.ts` files the PR touched — its changed-file diff uses `--diff-filter=d` so a PR that only _deletes_ a `src/lib` file (nothing left to mutate) doesn't crash the job trying to mutate a file that no longer exists.
- `ci.yml` — main CI pipeline, four jobs plus three PR-only gates: harness integrity (`.claude/verify-harness.sh`), `pnpm check`/`pnpm exec vitest --run --coverage`/coverage with an 80% changed-line gate (`diff-cover`); a separate `next build` job with dummy Supabase env vars; a Playwright e2e smoke job; a CHANGELOG-required-for-`src/`-changes gate (`skip-changelog` label bypasses); a README-freshness gate requiring every changed folder's `README.md` also be in the diff (`skip-readme-check` label bypasses) — the CI-time counterpart to `.husky/lib/readme-coupling.sh`'s commit-time nudge; a comment-hygiene gate scanning only the PR's added lines (`git diff -U0`) for change-narration comments, using the first 10 (hard-precision) lines of `.claude/comment-hygiene-patterns.txt` (`skip-comment-check` label bypasses) — the CI-time hard gate counterpart to `.husky/lib/comment-hygiene.sh`'s commit-time warn-only nudge and `.claude/hooks/post-edit-comment-check.sh`'s live edit-time nudge, both of which scan the full 13-line pattern file. Also a `db` job (migrations + pgTAP RLS) and a PR-only, advisory `mutation` job that Stryker-mutates whichever `src/lib/*.ts` files the PR touched — its changed-file diff uses `--diff-filter=d` so a PR that only _deletes_ a `src/lib` file (nothing left to mutate) doesn't crash the job trying to mutate a file that no longer exists; type-only `src/lib/db-types/` files are filtered out too, since Stryker finds no tests for them, and a PR with nothing left to mutate exits 0.
- `security.yml` — secret scan (gitleaks, full history) + the fail-closed `.claude/deps-gate.sh` dependency audit (`pnpm audit --prod`, high/critical severity); no CodeQL job, since code scanning requires GitHub Advanced Security which isn't available on this private repo's plan The gitleaks job installs the pinned release binary and checks its SHA-256, because gitleaks-action needs a paid license on organization-owned repos. It scans the PR commits, or the pushed range on `main`.

- `staging-sync.yml`: on push to `main` (or a manual run), fast-forwards the
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ jobs:
git fetch origin "$GITHUB_BASE_REF" --depth=1
CHANGED=$(git diff --name-only --diff-filter=d "origin/$GITHUB_BASE_REF...HEAD")
FILES=$(printf '%s\n' "$CHANGED" | awk '
/^src\/lib\/.*\.ts$/ && !/\.test\.ts$|\/types\.ts$|\/action-result\.ts$|^src\/lib\/supabase\// {
/^src\/lib\/.*\.ts$/ && !/\.test\.ts$|\/types\.ts$|\/action-result\.ts$|^src\/lib\/supabase\/|^src\/lib\/db-types\// {
printf "%s%s", separator, $0
separator = ","
}')
Expand Down
1 change: 1 addition & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3adfac34aa5faadc17b89edfc8e8e7b0be872da0:e2e/core-flow.spec.ts:generic-api-key:10
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ All notable changes to loopkit are documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [0.8.1] - 2026-12-02

### Added

- Playwright core-flow e2e: a vendor creates a stamp card program, a customer joins from the shop link with a phone number and a birthday, and the vendor stamps that card at the counter and sees the count update. The Supabase stand-in now keeps state across requests (table functions, RPC handlers).

## [0.8.0] - 2026-12-02

### Added

- A customer can spend an earned reward at qkit checkout. "Use at qkit checkout" on a reward marks it redeemed and shows a single-use `LK-` code from qkit, with a copy button, in one transaction (migration `0073`, `customer_use_voucher_at_qkit`; a retry returns the same code, and a spent reward stays on /c as "qkit code issued" with a "Show code" button). Vendors set what the code is worth (percent or dollars off) in Profile under "qkit reward code". Free for every vendor. The code expires when the reward does, and the value takes at most two decimals. The customer card list (`customer_join`) now also lists each card's active rewards, which /c never showed before.

## [0.7.1] - 2026-12-02

### Fixed

- New push-provisioned vendors get a default stamp program named "Stamp card" instead of "Starter" (migration 0073), which read as the retired pricing tier. Existing programs keep their names.
- The Plan page links "Merqo account" to the Merqo dashboard, and the legacy "starter" entitlement tier is normalised to Pro instead of being rejected for loopkit.

## [0.7.0] - 2026-12-02

### Changed
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ src/lib/merqo-customer-notify.ts — notifyCustomerByPhone/notifyVendor: kit →
src/lib/merqo-vendor-status.ts — reports status/metrics to merqo over HTTP
src/lib/supabase/ — browser / server / service clients (schema: loopkit)
src/components/ — wheel, scratch-card, flame-layers, cup, points-bar, stamp-dots, etc.
supabase/migrations/ — SQL schema + RLS
supabase/migrations/ — SQL schema + RLS (0074: qkit reward codes)
```

Touch devices (@media (pointer: coarse)) get 44px minimum buttons and fields; desktop density is unchanged. See src/app/globals.css.
Expand Down Expand Up @@ -510,7 +510,7 @@ See `AGENTS.md` for engineering rules and skills. `AGENTS.md` is kept under 200
- `.github/` — CI workflows
- `.husky/` — git hook scripts (pre-commit/commit-msg/pre-push)
- `docs/` — deploy runbook, superpowers specs/plans, CONSTITUTION
- `e2e/` — Playwright end-to-end smoke + signed-out route-protection tests (both run without Supabase provisioning)
- `e2e/` — Playwright end-to-end smoke, signed-out route-protection and core vendor/customer flow tests (all run without Supabase provisioning)
- `src/` — application source (App Router pages, lib, components)
- `supabase/` — SQL migrations and seed data
- `test/` — Vitest unit/integration tests
Expand Down Expand Up @@ -556,3 +556,5 @@ Vendor-facing plan-limit copy states what the plan includes and never asks the v
Route loading skeletons come from `@merqo/ui` (`ListSkeleton`, `StatTileSkeleton`, `DataTableSkeleton`) under `components/loading-header.tsx`. The counter and setup edit-impact dialogs use the shared `ConfirmDialog`, and the counter empty state uses `EmptyState`. The login and reset-password forms stay local because their zod and React Hook Form validation, wordmark shell and reset-sent notice are not covered by the shared forms. Touch targets on setup chips and overview program links reach 44px on coarse pointers, and visit bars are tappable.

Customer-facing selects and buttons (`birthday-field.tsx`, `check-form.tsx`, dashboard `scan-button.tsx`) use the shared `@merqo/ui` Select and Button primitives with 44px touch targets. `/c` without a shop link shows a next-step message and a link home.

New vendors get a default program named "Stamp card" (migration 0073); the plan page links to the Merqo account and treats the legacy "starter" tier as Pro.
2 changes: 1 addition & 1 deletion docs/DEPLOY.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ Do the steps in order: **A (Supabase) → B (Vercel) → C (attach to merqo)**.
- apply `0032_loopkit_provision_default_program.sql` — adds
`provision_default_program(p_vendor_id)`, a service-role-only SECURITY
DEFINER function (never granted to `authenticated`) that seeds a default
"Starter" stamp program for a push-provisioned vendor, since
"Stamp card" stamp program for a push-provisioned vendor, since
`create_program` is keyed on the calling session's `auth.uid()` and can't
run on a vendor's behalf. Advisory-lock-guarded against a double-provision
race, idempotent on `loopkit.programs`. Backs
Expand Down
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ spec/plan development history.
## Parent

[loopkit](../README.md)

Deploy notes refer to the default program new vendors receive as "Stamp card".
3 changes: 2 additions & 1 deletion e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Playwright end-to-end smoke tests — runnable with only `pnpm dev` +
- `route-protection.spec.ts` — signed-out route protection: `/dashboard`, `/dashboard/customers`, and `/setup` redirect to `/login`; `/admin` 404s rather than revealing the route exists; `/c` without `?v=` and `/earn` without `?order=` (copy: "This link is incomplete. Ask the shop for a new one.") render their no-DB-call fallback copy instead of attempting a lookup. Like `smoke.spec.ts`, runnable without Supabase provisioning — middleware's `getUser()` resolves `user: null` locally with no session cookie, so these gates fire without a live DB.
- `smoke.spec.ts` — public smoke: the landing page renders its hero heading and "Join the waitlist" link; `/login` renders its "Continue with Google" button. The hero heading locator (here and in `csp.spec.ts`) accepts either hyphen in "one-time", because the hero uses a non-breaking hyphen (U+2011)
- `signed-in-smoke.spec.ts`: signed in as an admin vendor with MFA cleared (`aal2`), `renderSmoke` over every dashboard (including the Customers referrals route and the old referrals/settings redirects), setup (`/setup` and `/setup/new`) and admin page, failing on a 5xx, error boundary, page error, CSP violation or 404; a password-only (`aal1`) admin session is sent to `/mfa`. It starts the stand-in below itself and runs in its own Playwright project after the others. It sees empty data, not seeded rows.
- `mock-supabase.ts`: not a spec; a small `http` server standing in for GoTrue and PostgREST, plus `signedInCookie()`, which builds the Supabase auth cookie for a signed-in session.
- `core-flow.spec.ts`: the core path end to end against a stateful stand-in: the vendor creates a stamp card at `/setup/new`, a customer in a separate browser context opens `/c?v=<vendor>`, enters a phone number and picks a birthday with the shared Select, then the vendor looks the number up at `/dashboard/counter` and adds a stamp; asserts the stored program, card, birthday and the on-screen `0 / 5` to `1 / 5` stamp count. It runs in its own `core-flow` Playwright project after `signed-in`, because it binds the same stand-in port. Camera scanning is not driven; the counter's phone lookup stands in for it.
- `mock-supabase.ts`: not a spec; a small `http` server standing in for GoTrue and PostgREST, honouring `offset`/`limit` and the app's keyset cursors so paged reads end, plus `signedInCookie()`, which builds the Supabase auth cookie for a signed-in session.

## Parent

Expand Down
Loading
Loading