Skip to Content
InternalDocsRunbooksP6 E Execution Checklist

P6 E Execution Checklist

Source: docs/runbooks/p6-e-execution-checklist.md

# P6-E Execution Checklist Execution checklist for `P6-E: Tenant Carrier Config + Agreement Import`. ## Scope - Implement tenant-specific carrier contract overrides used by SHIP detection. - Add agreement import pipeline for carrier contract CSVs. - Keep behavior backward-compatible with existing fallback chain. ## Constraints - No breaking API/response changes. - Keep fallback path safe: tenant override -> `ref.carrier_rules` -> hardcoded defaults. - Preserve existing detector behavior when tenant config is absent. ## Slice 1: Read Path + Fallback Chain - [x] Extend detector context for tenant carrier override inputs. - [ ] Add active contract-version resolver by `shipDate`. - [x] Apply tenant overrides in SHIP variance/deadline calculation path. - [x] Preserve fallback behavior when no tenant override exists. - [ ] Add tests: - [x] Uses tenant dim divisor when present. - [x] Uses global/default dim divisor when tenant override absent. - [x] Uses tenant claim-window override when present. - [x] Falls back to global/default claim-window when absent. ## Slice 2: Schema + Migration - [x] Add Prisma models: - [x] `CarrierAccount` - [x] `CarrierContract` - [x] `CarrierContractVersion` - [x] `CarrierServiceCode` - [x] Add migration with rollback note. - [x] Add follow-up DB guard constraints migration: - [x] Check constraints for numeric/date invariants on `carrier_contract_versions` - [x] Exclusion constraint preventing overlapping ACTIVE effective-date ranges per contract - [x] Run migration preflight checks: - [x] Ordering against latest `main` - [x] Fresh DB apply (`prisma migrate reset --force --skip-seed`) - [x] Existing DB apply (`prisma migrate deploy`) - [x] Tenant isolation implications documented ### Tenant Isolation Notes (Slice 2) - `app.carrier_accounts` is tenant-scoped via `tenant_id`. - `app.carrier_contracts` and `app.carrier_contract_versions` inherit tenant scope via FK chain: `carrier_contract_versions -> carrier_contracts -> carrier_accounts`. - `app.carrier_service_codes` is global reference/canonicalization data (not tenant-scoped). - RLS implication: existing P5-A policies do not yet include the new carrier account/contract tables. Until a dedicated RLS follow-up migration lands, isolation remains application-enforced (`req.orgId` scoping and tenant-bound joins). Add RLS policies before exposing broad read/write surfaces for these tables. ## Slice 3: Agreement Import - [x] Add upload endpoint: `POST /api/carrier/agreements/upload`. - [x] Hash dedupe via `ingestion_batches`. - [x] Parse CSV -> normalized contract payload. - [x] Upsert account + contract + version records transactionally. - [x] Persist source provenance (file hash, retrieval/import time). ## Slice 4: Contracts + Docs + Closeout - [x] Add/extend contract tests for new endpoint and read-path behavior. - [x] Update Postman collection for new carrier agreement endpoint. - [x] Update `CLAUDE.md` endpoint table. - [x] Update `docs/EXECUTION_PLAN.md` status and completion notes. - [x] Add `docs/SESSION_LOG.md` entry with final decisions and deferreds. ## Parallel Work (Other Agent) Safe to run in parallel while core branch handles schema/read-path: - [ ] Draft onboarding runbook for P6-F in `docs/runbooks/customer-onboarding.md`. - [ ] Draft Postman request examples for onboarding/setup endpoints (no code changes). - [ ] Prepare API contract stubs for P6-F admin setup routes. Do not run in parallel: - Migration lane edits touching P6-E schema files. - SHIP detector pipeline refactors overlapping fallback chain implementation.