Skip to content

Guest demo: sample data, purge cron, guest UI and docs (3/3) - #16

Merged
DHYEY166 merged 5 commits into
mainfrom
feature/guest-demo
Oct 2, 2026
Merged

DHYEY166 merged 5 commits into
mainfrom
feature/guest-demo

Conversation

@DHYEY166

@DHYEY166 DHYEY166 commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Stack: 3 of 3. This PR's base is feature/guest-limits (#15), which is stacked on #14. Merge #14, then #15, then this one, retargeting each to main as the one below it merges.

What

  • src/lib/erase-team.ts. The S3-then-DB erasure from DELETE /api/account moved here unchanged; it now also deletes the guest_sessions row. The account route is now a thin wrapper.
  • GET /api/cron/purge-guests (Bearer CRON_SECRET):
    • Erases up to 20 guests per call: expired sessions, plus guest_ teams older than 24 h with no live session.
    • Skips teams with a run in flight and never touches non-guest ids.
    • Keeps bedrock_usage so the all-guests daily AI cap stays correct.
  • Sample data.
    • Migration 003 now also seeds a fixed, non-public demo template (ON CONFLICT DO NOTHING, no semicolons inside statements).
    • POST /api/sample-data creates a pipeline on that template and does a server-side PutObject of the bundled CSV, so the profiler runs normally and suggest-transforms takes the template path. Bedrock cost is $0.
    • For guests it counts as an upload and a pipeline.
  • UI:
    • "Try as guest" on the landing and sign-in pages. It renders only when guest access is on, with an optional Turnstile widget.
    • A guest banner in the Nav: time left, "Sign up to keep your work", "End session".
    • Templates, the Chat Builder tab, auto-clean and training export are hidden for guests.
    • "Try with sample data" on the dashboard.
    • The real per-file limit is shown in the upload form and on the landing page.
  • CSP. Adds https://challenges.cloudflare.com to script-src and frame-src only when NEXT_PUBLIC_TURNSTILE_SITE_KEY is set at build time.
  • Docs. README sections for guest access, the purge schedule (EventBridge hourly; Vercel Hobby only allows daily crons, so vercel.json is unchanged) and the S3 lifecycle backstop. CONTRIBUTING covers the erasure rule.

Verified (locally)

  • tsc, lint (0 errors), vitest: 235 passed.
  • Integration: 25 passed. New guest-demo.test.ts runs sample data → real profiler → template rules with 0 bedrock_usage rows → approve → real executor → a pinned clean file. The purge then erases every S3 version and the rows, keeps bedrock_usage, and leaves a live guest and a user untouched.
  • e2e: 12 passed, including the full flow: Try as guest (sign-in page) → banner → sample data → 6 rules → approve → completed → download equals the pinned file → End session → /dashboard redirects to sign-in.

DELETE /api/account's S3-then-DB erasure moves to src/lib/erase-team.ts
unchanged (it now also deletes the guest_sessions row) so the guest purge
cannot drift from it. The cron (Bearer CRON_SECRET, 20 per call) erases
expired guest sessions and guest_ teams over 24 h old without a live
session, skips teams with a run in flight, never touches non-guest ids,
and keeps bedrock_usage so the all-guests daily AI cap stays correct.
POST /api/sample-data creates a pipeline on a fixed demo template (seeded
idempotently in 003, not public) and writes the bundled CSV to the raw
bucket server-side, so the normal profiler path runs and suggest-transforms
takes the template branch: $0 Bedrock. It counts as an upload and a
pipeline for guests (capped inserts) and removes the empty pipeline when
over the cap. Only s3:PutObject is needed, which uploads already require.

The integration test runs it through the real profiler and executor to a
pinned clean file, then purges the expired guest.
Landing and sign-in pages get a "Try as guest" button that renders only
when guest access is on, with a Turnstile widget when the site key is set
(CSP then allows challenges.cloudflare.com in script-src and frame-src).
The Nav shows a banner with the time left, "Sign up to keep your work" and
"End session", and hides Templates; the chat builder tab, auto-clean and
training export are hidden for guests. The dashboard gets "Try with sample
data" and explains a blocked-feature redirect. GET /api/guest no longer
reports a stale guest cookie for a signed-in user. Upload form and landing
page show the real per-file limit.
@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clean-stack Ready Ready Preview Oct 2, 2026 5:27pm UTC
cleanstack Ready Ready Preview, v0 Oct 2, 2026 5:27pm UTC

@DHYEY166
DHYEY166 merged commit e6412c2 into main Oct 2, 2026
9 checks passed
@DHYEY166
DHYEY166 deleted the feature/guest-demo branch October 2, 2026 17:30

This branch was successfully deployed

2 active deployments
Preview – cleanstack — 8dc17274 Deployed Oct 2, 2026 by vercel[bot]
Preview – clean-stack — 8dc17274 Deployed Oct 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant