Feelcouch ProjectsHandbook · v1.47.0

Guides

Identity 2.0 core acceptance audit

The consent/baseline server-write findings below were corrected in v1.22.1. The new eligibility helper was tested against real disposable PostgreSQL records; the full gate passed346tests with no skips. Original findings remain as audit evidence. Document/configuration/version policy findings remain open. See current acceptance status.

Audited 2026-09-30 against platform-docs/guides/identity-2.md and task specifications FC-DATA-001, FC-LEGAL-001, FC-BOT-006 and FC-ONB-002. This is a source and local-test audit; production tenant settings, participant records and Telegram delivery were not inspected. The guide's "works on psicho" status is a deployment claim, not evidence that all required tenant content has been configured.

Implemented acceptance

Item Source evidence Assessment
FC-DATA-001 prisma/migrations/20260930100000_identity_scenario/migration.sql:1 through the five profile foreign keys at lines 138–156 Additive tables, defaulted/nullable columns and cascades are present. No destructive statement in this migration. This audit did not repeat a migration-diff comparison.
FC-LEGAL-001 lib/legal-documents.ts:15, app/actions/legal-documents.ts:13, app/onboarding/page.tsx:83, components/participant/legal-consent-form.tsx:35, app/actions/privacy.ts:11, app/(app)/layout.tsx:43 Stable metadata version; HTTPS editor with audit; summary/link cards; required health checkbox when documents exist; current-version gate. Matches the task's explicit metadata hashing and no-documents fallback.
FC-BOT-006 lib/telegram/onboarding.ts:14, app/api/telegram/webhook/route.ts:55, app/actions/privacy.ts:54, components/facilitator/bot-settings-form.tsx:11, app/actions/bot-settings.ts:26 Four pre-consent messages, 2-second delay, document links and accept button; fifth message after consent; already-consented users receive only message five. Five fields are editable and RU defaults match the scenario in i18n/catalogs/v1/ru.json:2102.
FC-ONB-002 app/(app)/layout.tsx:50, components/participant/baseline-screen.tsx:12, app/actions/baseline.ts:17, app/actions/baseline-setup.ts:15, app/f/baseline/page.tsx:23 Active questionnaire gate, all-links HTTPS validation, transactional result upserts, submitted timestamp, notifications to facilitators, add/edit/deactivate/order forms and indicator options exist. No active questionnaires means no gate.
Personal-data lifecycle app/api/account/export/route.ts:99, lib/account-deletion.ts:4, tests/integration/account/export.test.ts:221 Export includes new self-owned data and private diary. Erasure helper removes restrictive author references while preserving another participant's discussion. Prior live disposable-database test in this session passed both export tests without skips.

Fresh targeted test run: legal-documents, baseline and bot-onboarding suites passed 12 tests, zero failures, zero skips. These are mainly predicate/message tests; they do not certify live PDF contents, production configuration or end-to-end Telegram delivery.

Remaining gaps and priorities

  1. P1 — Baseline submit can bypass consent. app/actions/baseline.ts:13 calls requireUser, then persists result links without the current-consent check used by health-data actions (lib/auth/current-user.ts:41, app/actions/daily-mood.ts:17, app/actions/diary.ts:15). The UI layout normally sends users to consent first, but a direct authenticated action call has no equivalent gate. Require current consent inside submission and add an action-level test.

  2. P1 — Baseline lock protects navigation, not all writes. The lock substitutes the baseline screen in app/(app)/layout.tsx:119; requireConsentedParticipant only validates consent (lib/auth/current-user.ts:41). For example saveDailyMood and saveDiaryEntry can still write when authenticated and consented but missing baseline results. Enforce the baseline gate for normal program mutations, with deliberate exceptions for baseline submission and account rights, if "the rest of the app is locked" is intended as a server-side requirement.

  3. P1 — Tenant readiness is not demonstrated. Source intentionally seeds no questionnaire definitions. getLegalState treats any nonempty document set as configured (lib/legal-documents.ts:49); there is no requirement that OFFER, PRIVACY and INFORMED_CONSENT all exist before opening the scenario. A tenant with zero questionnaires skips Point A; with zero documents it uses the legacy consent fallback. Confirm all three reviewed documents, actual questionnaire links and indicator definitions through authorized non-sensitive settings checks. Deployment version alone cannot establish readiness. Add a scenario readiness check without changing fallback behavior for other tenants.

  4. P2 — Replacing a PDF at the same URL does not invalidate consent. The version hashes kind/title/summary/URL, not document bytes (lib/legal-documents.ts:17). This follows FC-LEGAL-001 exactly but is narrower than the scenario's "any document change" wording. Use immutable versioned PDF URLs and change the saved URL whenever content changes, or design a stored revision/digest. The application only validates HTTPS, not document availability or PDF content (app/actions/legal-documents.ts:23); supplying the correct PDFs remains tenant setup.

  5. P2 — "Point A once" needs an explicit configuration-change rule. The guide says the screen appears once, but the layout compares current active IDs with saved results on every visit (app/(app)/layout.tsx:51). Adding a new active questionnaire relocks previously completed participants despite baselineSubmittedAt. This agrees with the task's all-active-results predicate. Decide whether questionnaires are frozen per cohort or adding one intentionally requires another submission; document and test that decision.

  6. P2 — The gate-open message is best effort, without durable retry. Consent is committed before direct Telegram send; send failures are caught and discarded (app/actions/privacy.ts:54). A subsequent /start can recover message five, but automatic delivery after acceptance is not guaranteed. If delivery is required, enqueue it through the existing notification path and cover failure/retry. TELEGRAM_WEBAPP_URL must also be configured: otherwise the open/accept WebApp buttons are omitted (lib/telegram/bot.ts:82).

No missing core schema or missing editor was found. The main remaining work is enforcing the baseline/consent boundary in actions and proving scenario configuration, followed by the smaller document-version, one-time baseline and Telegram retry decisions above.