Skip to content

feat(report): report access on by default under its own switch; stricter unlock - #164

Merged
razel-hash merged 2 commits into
mainfrom
lane/aeo-gate-enforce
Nov 16, 2026
Merged

razel-hash merged 2 commits into
mainfrom
lane/aeo-gate-enforce

Conversation

@razel-hash

Copy link
Copy Markdown
Collaborator

What

Report access gets its own switch, AEO_REPORT_GATE, and is on by default. It no longer waits for the run gate (AEO_GATE_MODE, still off by default).

  • Report access (report page, status API, print view, custom questions): without the per-audit unlock cookie the server sends only the preview. Values: unset/enforce (default), observe (log only), off (the off switch).
  • Unlock proof key: AEO_UNLOCK_COOKIE_SECRET when set, otherwise an HKDF key derived from the server's database key, so no new setting is needed. With no key at all, reports stay locked.
  • Unlock route: refuses a non-UUID id (400); an audit that isn't finished or has no results (409, as before but now by default); reserved example/test email domains (400). The same email on the same audit unlocks again with no second write and no CRM call. Each audit accepts at most 5 different emails (429). Requests that pass that check together are counted again after writing, and the ones past the limit get no CRM sync and no cookie.
  • Staff unlock as before (no form, no lead, no CRM). Their cookie now lasts the browser session, so it doesn't pile up.
  • npm run gate:check prints the report gate on its own line. Guide and CLAUDE.md updated.

Before this goes live (owner)

  • Anyone who opens a report link without unlocking sees the preview, CC reps opening it from the CRM included. Reps should be on AEO_STAFF_EMAILS and signed in, which needs draft 008 applied first (see feat: staff mode (sign-in + allow-list; no lead, cap exempt; ships inert) [rebased #160] #162). Otherwise they unlock with the prospect's email, which writes nothing new.
  • Visitors who unlocked before this change have no cookie, so they see the form again; the same email unlocks with no new write.

Pipeline: /tdd (gate.report.test 8 red first; unlock id/address/repeat/limit cases 8 red, the after-write limit and staff-session cases 2 red; route specs updated where they assumed "unset = off") → code-reviewer subagent → /security-review

Risk tier: high (public route, lead data)

Risk

  • Production behaviour changes on deploy: full reports need an unlock. Rollback: set AEO_REPORT_GATE=off and redeploy, or revert.
  • If AEO_UNLOCK_COOKIE_SECRET is later set or the database key rotated, earlier unlocks re-lock; visitors unlock again.
  • A real sixth reader of one shared report is refused and told to run their own audit.

Code review: the code-reviewer subagent found no leak or forgery path. It raised: concurrent requests could beat the 5-reader limit (fixed: recount after the write gates CRM and cookie, with a test); staff cookies lasting a year (fixed: session cookie, with a test); the HKDF test was too weak (fixed: compared against a proof signed with the raw key); a guide line missing the status API's preview tips (fixed). CRM reps seeing the preview is an ops step, listed above. Pre-existing and left as is: staff can't run custom questions on an audit with no public lead.

Security review: no findings at confidence ≥ 8 (proof bound to the audit id, constant-time compare, every reader of report data checks access, no PII in new log lines).

Checks: npx vitest run 273/273 in 25 files; npx tsc --noEmit clean; eslint on changed files 0 errors.

🤖 Generated with Claude Code

razel-hash and others added 2 commits November 17, 2026 07:18
…k checks the id, the address and repeat readers

AEO_REPORT_GATE (enforce unless off/observe) now governs report access and unlock
readiness, separate from the run gate. The unlock proof key falls back to an HKDF key
derived from the server key, so no new setting is needed. Unlock refuses a non-UUID id,
reserved example/test email domains, and a sixth distinct email per audit; a repeat
email unlocks without a second write or CRM call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sts the session; doc and comment wording

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
campaign-creators-aeo-auditor Ready Ready Preview Nov 16, 2026 11:49pm UTC

Request Review

@razel-hash
razel-hash merged commit 61b85fa into main Nov 16, 2026
3 checks passed

This branch was successfully deployed

1 active deployment
Preview — a2bdc0da Deployed Nov 16, 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