# Deployment and evidence runbook

## Choose the smallest route

For an interview or initial investigation, run individual `sql/direct-live/AP*.sql` SELECTs; no application deployment is needed. Record account, role, warehouse, toolkit hash, actual query IDs, time, scope and interpretation in the approved evidence location. The query's default is seven complete UTC days ending three days before current UTC midnight, to leave an ingestion buffer; agree a representative window with owners. A thirty-day operational baseline and ninety-day cost trend may be appropriate after sources and workload seasonality are confirmed. Defaults are not client SLOs or policy.

No metadata source guarantees full visibility. Account Usage privileges, edition, feature support, retention and latency must be checked. Query-history database is compilation context, not complete accessed-object lineage. The snapshot role, user, column, policy, table and dependency views describe captured current state, not historical state for the workload observation window.

## Deploy a reporting layer in a new namespace

Have the authorized operator inspect all SQL first, including Snowflake Scripting blocks. Working analysis roles should be least privilege; do not require ACCOUNTADMIN as the analyst role. Use an approved small warehouse, statement timeout and scoped source privileges. Do not execute client production remediations as part of this pack.

1. Confirm `SF_EVAL_REVIEW_20261105` is unused. Run `sql/setup/00_create_new_database.sql` **once**. It creates its own database and typed RAW, SOURCE, META, ANALYSIS and REPORTING objects. A collision must fail; never add IF NOT EXISTS or OR REPLACE to adopt a database. If any script fails, capture error/query ID and inventory created objects; stop that sequence instead of blindly rerunning it.
2. Set exactly one `META.ASSESSMENT_CONFIG` record with a unique assessment run ID, approved UTC window, optional warehouse/database filters and agreed heuristic values. The generated V_CONFIG rejects missing/invalid or duplicate configuration. A database filter in workload SQL restricts compilation context; it is not an access boundary. RBAC graph collection requires account-level topology.
3. Choose **one** adapter: `01_source_from_copies.sql` for typed RAW tables, or `02_source_from_live.sql` for ACCOUNT_USAGE. These are state-changing project-owned view setup scripts. They clear source attestations before retargeting. On privilege or missing-feature failure stop, record the partial setup and qualify only the dependent check after resolving its evidence route; do not represent all sources as present.
4. For AP11, the privacy owner supplies approved `META.APPROVED_SENSITIVE_COLUMNS`: object identifiers, classification, whether masking is required, approval reference and sample-population flag. An empty or placeholder inventory cannot prove that sensitive data is protected. No patient-row profiling is performed. Runtime masking and downstream copies require separate evidence.
5. Run `03_analysis_views.sql`, then `04_reporting_views.sql`. Each checks the project ownership marker before changing only project objects. These scripts require their declared sources. If a required source is unavailable, record the gap and use the relevant standalone queries rather than inventing tables or substituting sample evidence.
6. Validate every source in `META.SOURCE_REGISTRY` for the run: mode LIVE/COPY/SYNTHETIC, status COMPLETE/PARTIAL/DENIED/UNSUPPORTED/EMPTY/UNKNOWN, captured timestamp for copies, exact window and warehouse/database extraction filters (NULL means no such filter), captured row count, named attester and substantive attestation. COMPLETE is a human-reviewed evidence decision, never inferred from a successful SELECT or nonzero row count. Source staleness/latency, visibility and collection coverage belong in that attestation. Omitted or duplicate rows remain unknown. Broadening or changing either configured filter invalidates prior completeness until the source is recollected or its scope revalidated and explicitly reattested. The pack does not automatically expire an approved source based on an arbitrary age threshold: reassess the approval before reuse.
7. Execute `REPORTING.V_COVERAGE`, inspect all check dependencies, then reporting SELECTs in `notebooks/sql/`. Compare actual values with source evidence and owner expectations. Record any native schema/SQL discrepancies. Capture hashes and actual query IDs; local test results do not substitute for these checks.
8. Deploy consumers only after the SQL layer is qualified for the exact environment. Read the separate notebook/dashboard guide. Review native app owner-rights access and permitted viewers before sharing.

## When direct access is denied

The client runs the bounded, explicit-column SQL under `sql/metadata-exports/` and delivers approved metadata in the client-approved location. The queries exclude raw SQL text, binds, error messages, file names and patient rows. Object and identity metadata may still be sensitive. RBAC role/user/grant topology is account-level even when object-analysis filters are narrow; negotiate that evidence scope explicitly. Do not strip role-grant edges by database filter and then claim effective-access completeness.

Save the exact query/version, actual query ID, role, capture UTC time, observation window, filters, row count, checksum, source limitations and visibility validation beside each export. A 10,000-row cap reached means PARTIAL; narrow a coherent scope or collect reviewed nonoverlapping partitions with complete reconciliation. Do not attest a truncated graph as complete. Matching counts alone do not prove equivalent privileges or schema.

Transfer only approved exports; load into the matching typed RAW table with an approved client-operated load method (for example Snowsight table loading). This toolkit does not activate stages, external integrations, paid features or upload data automatically. Map columns by explicit name/order and preserve nulls, booleans, timestamps/timezones and VARIANT values. Reject a schema mismatch. Reconcile the imported rows/checksum/period with the original export; record any conversion. For refreshes use a newly reviewed run/capture and replace data only under an explicit approved loading plan; the analysis app never loads or rewrites data.

Keep live and copied populations coherent. Query attribution and metering must cover the same completed windows and compatible standard warehouse population. Serverless, AI, cloud services, storage, transfer and Adaptive Warehouse-specific metering are outside the AP12 subtraction; its result is diagnostic, never guaranteed avoidable spend or currency savings. Cost reconciliation to the actual bill is a separate assessment procedure.

## Synthetic rehearsal

`fixtures/metadata.json` contains synthetic metadata stories with healthy, problematic and unknown cases, never Acaria telemetry. After creating a **fresh empty lab namespace**, select that new database as the current database, then inspect/run `05_synthetic_fixture.sql`: it is state-changing seed data for RAW and META, blocked for nonempty RAW tables and marked SYNTHETIC. Select the copy adapter, then create analysis/reporting views. Do not relabel these synthetic records as client evidence. The seed uses its own fixed observation window; do not run it against today's moving default window.

Offline tests execute translated SQL on this fixture and compare source-switch results. Native rehearsal still needs the approved account, package, query IDs, actual outputs and rendered-page evidence. Test every page: Executive, Spend, Performance, Security, Operations and coverage. Inject denied/partial sources and confirm UNKNOWN without a fabricated healthy fallback. Keep the same release hashes in the handover.

## From result to advisory recommendation

For every material candidate record: practice ID → check/query version → approved source/run/window → measured observation → owner validation → business consequence → causal hypothesis/test still needed → options → proposed roadmap package. Include what works, what is unassessed and what is disputed. A remediation suggestion becomes an accountable next-phase package only after scope, owner, prerequisites, indicative effort and future acceptance are agreed. Nothing in this assessment authorizes implementation.

## Expanded source handling

There are56typed sources. Setup00creates default SOURCE views over RAW, so an unavailable native feature does not stop unrelated view definitions from compiling. In live mode, each native retarget is isolated; failure keeps the prior typed source and records UNKNOWN with SQLCODE. Inspect the registry and classify denied/unsupported/schema failures from actual operator evidence; a successful setup block is not collection completeness. SHOW, profile and approved-input sources stay captured in RAW even in live mode. Every required source remains unverified until its own truthful attestation.

Default ACCESS_HISTORY exports preserve array cardinalities with count-only markers and omit original names/column payloads. They support count diagnostics; AP69willremainUNKNOWN. `ACCESS_HISTORY_IDENTIFIERS_APPROVAL_REQUIRED.sql` is an optional, separately approved projection of direct/base objectName only. Object identifiers can still be sensitive. No original column arrays, external locations, query text or patient records belong in those exports. The transformations use documented Snowflake [TRANSFORM](https://docs.snowflake.com/en/sql-reference/functions/transform).
