v22.0 Phase 0 Implementation Plan (2-Week Baseline + Instrumentation)
Summary
Phase 0 establishes the evidence and measurement foundation required before any Phase 1 pilot build work.
Primary outcomes:
- Baseline metrics computed and reproducible.
- Privacy-safe instrumentation implemented without query-text logging.
- 211 integration feasibility decision recorded (
go,conditional,blocked). - Offline/local storage threat model completed with no unresolved critical findings.
- Pilot-scope readiness reporting available without mutating curated service data.
This plan is execution-ready and decision-complete for implementation.
Implementation Progress (2026-04-01)
Completed:
- Workstream B instrumentation plumbing is implemented (types, schemas, routes, storage).
- Pilot DB schema and RLS migrations are applied and verified in Supabase.
- Missing-table safety behavior is preserved with explicit
501responses. - Pilot API/schema/metrics automated tests are implemented and passing.
- D1-D7 approval lock completed (
v22-0-approval-checklist.md). - Integration feasibility decision captured in conditional mode with controls C1-C3.
- Threat-model owner/due-date mitigation matrix completed with no unresolved critical findings.
- Baseline report artifact created in Gate 0 minimum mode.
- SQL Editor execution runbook and query helper script added for baseline M1/M3 execution.
- Gate 0 evidence status tracker added for centralized closure tracking.
- Baseline M1/M3 execution completed (window: 2026-02-10 to 2026-03-09) and recorded in baseline report.
- Extended metric sources for M2/M4/M5/M6/M7 are implemented via additive schema, internal APIs, and recompute-to-snapshot flow.
- Pilot-scope readiness audit/export tooling is implemented for JSON, Markdown, and CSV outputs without changing
data/services.json. - Public claim hardening and focused pilot/privacy route coverage are complete for the Tier 0 admissions-support bundle.
Remaining:
- Complete the remaining conditional integration control C1 before external activation.
- Populate the new metric source tables with real pilot-window events and run a fresh non-historical baseline/scorecard.
- Execute the bounded verification and pilot-scope data-quality follow-through that the new readiness tooling now exposes.
Gate decision control:
Scope
Included:
- Baseline metric definitions, data dictionary, and reproducible calculation queries.
- Pilot event contracts and internal APIs for contact attempts and referral outcomes.
- Integration feasibility decision workflow with redline enforcement.
- Threat model execution for offline/local storage confidentiality and integrity.
- Gate 0 evidence package assembly.
Excluded:
- Phase 1 pilot feature implementation (service reliability UI/workflows, referral UX expansion).
- Search ranking policy changes for stale/unavailable services.
- Public launch preparation or v19 execution tasks.
Hard Constraints (Non-Negotiable)
- No raw user query text persistence in database, logs, or telemetry payloads.
- All API write paths must use Zod validation and explicit allowlists.
- All Supabase operations in new routes must be wrapped with
withCircuitBreaker(). - All protected write routes must enforce authorization checks (
assertPermissionor stricter equivalent). - Any unresolved critical threat-model finding blocks Gate 0 completion.
Public API / Interface Impact
No new public, unauthenticated API endpoints are introduced in Phase 0.
Phase 0 introduces internal authenticated pilot endpoints only:
POST /api/v1/pilot/events/contact-attemptPOST /api/v1/pilot/events/connectionPOST /api/v1/pilot/events/referralPOST /api/v1/pilot/events/service-statusPOST /api/v1/pilot/events/data-decay-auditPOST /api/v1/pilot/events/preference-fitPATCH /api/v1/pilot/events/referral/{id}POST /api/v1/pilot/scope/servicesPOST /api/v1/pilot/metrics/recomputeGET /api/v1/pilot/metrics/scorecardPOST /api/v1/pilot/integration-feasibility
These endpoints are internal to pilot operations and governance workflows.
Data Contracts (Decision-Locked)
Type Additions
Add new type files:
types/pilot-contact-attempt.tstypes/pilot-referral.tstypes/pilot-metrics.tstypes/integration-feasibility.ts
PilotContactAttemptEvent
Required fields:
id(string UUID)pilot_cycle_id(string)service_id(string)attempt_channel(phone|website|email|in_person|referral)attempt_outcome(connected|disconnected_number|no_response|intake_unavailable|invalid_routing|other_failure)attempted_at(ISO timestamp)recorded_by_org_id(string)entity_key_hash(SHA-256 hex digest; opaque repeat-failure attribution key)
Optional fields:
resolved_at(ISO timestamp)outcome_notes_code(enumerated code only, no free text)
Disallowed fields:
- Raw search query text
- User message text
- Direct personal identifiers
- Raw identifiers used to derive
entity_key_hash
PilotReferralEvent
Required fields:
id(string UUID)pilot_cycle_id(string)source_org_id(string)target_service_id(string)referral_state(initiated|connected|failed|client_withdrew|no_response_timeout)created_at(ISO timestamp)updated_at(ISO timestamp)
Optional fields:
terminal_at(ISO timestamp)failure_reason_code(enumerated code only)
Disallowed fields:
- Free-text notes containing user details
- User query text
- Personal contact data
IntegrationFeasibilityDecision
Required fields:
decision(go|conditional|blocked)decision_date(ISO date)redline_checklist_version(string)violations(array of predefined violation codes)compensating_controls(array; required whendecision=conditional)owners(array of owner IDs or role labels)
Schema Validation
Create Zod schemas:
lib/schemas/pilot-events.tslib/schemas/integration-feasibility.ts
Validation rules:
- Strip unknown keys and reject disallowed keys.
- Enforce enumerations for outcome/failure fields.
- Enforce timestamp/date ISO format validation.
- Reject payloads containing keys:
query,query_text,message,user_text,notes.
Route-Level Security Model
Write endpoints
- Require authenticated session.
- Require organization-scoped write permission via
assertPermission(..., "canCreateServices")or stronger. - Apply rate limits:
- Contact/referral writes: 60 requests/minute per IP.
- Integration decision writes: 10 requests/minute per IP.
- Set
Cache-Control: no-storeon responses.
Read endpoint (/pilot/metrics/scorecard)
- Require authenticated session.
- Require analytics access via
assertPermission(..., "canViewAnalytics")or admin role. - Return only aggregated statistics; no event-level PII.
Workstreams and Timeline
Week 1 (Days 1-5)
Workstream A: Baseline Definitions + Data Dictionary
- Lock formulas for M1-M7 as defined in v22 strategy doc.
- Produce a metric data dictionary with:
- metric name
- formula
- numerator/denominator source
- freshness expectation
- known limitations
- Build reproducible baseline query set for 4-week pre-pilot window.
Deliverables:
- v22.0 Phase 0 Baseline Metric Definitions
- v22.0 Phase 0 Baseline Query Spec
- v22.0 Phase 0 Baseline SQL Editor Runbook
Workstream B: Instrumentation Plumbing
- Add pilot types and Zod schemas.
- Add internal pilot endpoints with auth, RBAC, and circuit breaker.
- Add recompute-to-snapshot scorecard calculation path for M1-M7.
- Add pilot-scope readiness reporting/export tooling.
- Ensure telemetry/logging paths never store raw query text.
Deliverables:
- Internal endpoint implementations.
- Unit/integration test coverage for route validation and privacy rejects.
- Readiness audit command and export artifacts.
Week 2 (Days 6-10)
Workstream C: 211 Integration Feasibility
- Execute redline checklist against candidate integration terms/flows.
- Record feasibility decision (
go,conditional,blocked). - If
conditional, document mandatory compensating controls and deadline. - If
blocked, lock contingency path and trigger conditions.
Deliverable:
Workstream D: Offline/Local Threat Model + Claim Re-Validation
- Execute threat model for offline/local data (lost/stolen device scenarios).
- Classify findings by severity (
critical,high,medium,low). - Define mitigations and owners for all
high/criticalfindings. - Complete evidence re-validation log for external-agent-derived claims.
Deliverables:
Gate 0 Package Assembly (Day 10)
Assemble:
- Baseline metrics report.
- Integration feasibility decision record.
- Threat model report.
- Re-validation log.
- Updated approval checklist with lock status.
Gate 0 Acceptance Criteria
All criteria must pass:
- Baseline values exist for instrumented metrics when qualifying source events exist, or are recorded as
NULL/N/Awith correct empty-window notes. - Measurement queries validated end-to-end against stored events and snapshot recompute.
- Integration feasibility decision recorded with rationale.
- Threat model has zero unresolved
criticalfindings. - Approval checklist shows 7/7 decisions locked.
Test Plan
Automated
- Route schema tests:
- Accept valid payloads.
- Reject unknown/disallowed text fields.
- Authorization tests:
- Write endpoints reject unauthenticated requests.
- Write endpoints reject insufficient permissions.
- Privacy regression tests:
- Attempt payloads with
query_textornotesand assert 400 rejection. - Scorecard aggregation tests:
- Validate metric outputs for controlled fixtures.
Manual
- Call each endpoint with authenticated and unauthenticated sessions.
- Verify metrics endpoint returns aggregate-only values.
- Trigger redline decision path for all three outcomes (
go,conditional,blocked). - Validate Gate 0 package completeness against checklist.
Rollout and Monitoring
- Keep pilot endpoints internal and undocumented for public consumers during Phase 0.
- Use existing observability stack (Axiom + Slack alerting) for endpoint failure monitoring.
- Add Phase 0-specific alert labels for:
- schema rejection spikes
- high 5xx rates on pilot routes
- scorecard compute failures
Explicit Defaults and Assumptions
- Pilot domain default is housing intake unless D3 changes.
- Pilot partner range default is 5-10 providers and 2-3 frontline orgs unless D4 changes.
- Integration decision is blocked from auto-upgrading; any move from
blockedorconditionaltogorequires explicit checklist update. - Phase 1 work remains blocked until Gate 0 criteria are passed and recorded.