Skip to content

fix: PERF-03 remove decorative mock encryption pipeline from assessment#137

Merged
MP2EZ merged 2 commits into
developmentfrom
fix/assessment-mock-encryption
Jun 6, 2026
Merged

fix: PERF-03 remove decorative mock encryption pipeline from assessment#137
MP2EZ merged 2 commits into
developmentfrom
fix/assessment-mock-encryption

Conversation

@MP2EZ
Copy link
Copy Markdown
Owner

@MP2EZ MP2EZ commented Jun 6, 2026

Audit-derived (/m:audit development --perf, finding PERF-03). No Notion work item.

The production assessment answer path ran four mock services on every tap (mockComplianceEngine, mockEncryptionService, mockAuditLogger, mockPerformanceMonitor) — including an artificial await setTimeout(10ms) + several console.logs, eating into the 300ms assessment budget. The mock also falsely claimed AES-256-GCM while storing encrypted_${JSON.stringify(data)} (a compliance smell).

The mocks were decorative: real AES-256 encryption, consent, audit logging, and crisis detection (inline PHQ-9 Q9 + score-based thresholds) all run downstream in assessmentStore.answerQuestionSecureStorageService. The mock output fed only a never-read local metadata/totalEncryptionTime counter.

  • Delete the four mock objects, the artificial delay, the console.logs.
  • Simplify handleAnswerSelection to call onAnswer(response) unconditionally and before anything that can throw (removes a latent consent-throw that could have suppressed a Q9 crisis alert); keep the a11y announcement + 300ms perf guard.
  • Simplify the onAnswer/ResponseMetadata contract; drop unused interfaces, the metadata arg, and write-only encryptionStatus state. Honest header (no in-component encryption claim).

Specialist passes: crisis + compliance (both APPROVE-WITH-CONSTRAINTS) — crisis detection/banner/button entirely store-sourced and untouched; no real consent/audit/encryption control lived only in the mock.

Safety gate: Maestro e2e:safety:{q9,phq9,gad7} all pass against the seeded no-dev-client build (Q9 single-alert, PHQ-9≥20, GAD-7≥15 → crisis banner). Plus test:clinical (94), test:crisis-detection (82) green.

🤖 Generated with Claude Code

MP2EZ and others added 2 commits June 6, 2026 02:10
Audit /m:audit --perf found the production assessment answer path running
four MOCK services on every tap (mockComplianceEngine, mockEncryptionService,
mockAuditLogger, mockPerformanceMonitor), including an artificial
`await setTimeout(10ms)` and several console.log calls — eating into the
300ms assessment budget. The mock also falsely claimed `AES-256-GCM` while
storing `encrypted_${JSON.stringify(data)}` (a compliance smell).

The mocks were decorative: real AES-256 encryption, consent, audit logging,
and crisis detection (inline PHQ-9 Q9 + score-based thresholds) all run
downstream in assessmentStore.answerQuestion -> SecureStorageService. The
mock output fed only a never-read local metadata/totalEncryptionTime counter.

- Delete the four mock objects, the artificial delay, and the console.logs.
- Simplify handleAnswerSelection to call onAnswer(response) unconditionally
  and before anything that can throw (removes a latent consent-throw that
  could have suppressed a Q9 crisis alert), keep the a11y announcement and
  the 300ms perf guard.
- Simplify the onAnswer/ResponseMetadata contract: onAnswer(response) only;
  drop the unused EncryptionResult/ResponseMetadata interfaces, the metadata
  arg, and the write-only encryptionStatus state. answers Map stores the
  response directly. Honest header comment (no in-component encryption claim).

Specialist passes: crisis + compliance (both APPROVE-WITH-CONSTRAINTS) —
verified crisis detection/banner/button are entirely store-sourced and
untouched; no real consent/audit/encryption control lived only in the mock.

Tests: updated EnhancedAssessmentQuestion contract test to the single-arg
onAnswer (still pins delegation + no component-fired Alert + store-sourced
banner). Validated: typecheck, lint:baseline (net -6 errors), test:clinical
(94), test:crisis-detection (82), test:unit (395) all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@MP2EZ MP2EZ merged commit 742e108 into development Jun 6, 2026
22 checks passed
@MP2EZ MP2EZ deleted the fix/assessment-mock-encryption branch June 6, 2026 19:15
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