Snowflake assessment tools

Deterministic assessment advice and traceability

This offline tool turns validated metadata into reviewable advisory observations. It runs the existing four SELECT analyses against the real normalized SQLite database; it uses no model, connector, network, credential or expected-answer lookup. Synthetic observations are rehearsals. Client metadata remains client metadata. Neither becomes an owner-validated finding automatically.

Use a fresh destination outside the checkout:

PYTHONPATH=src python -m sf_eval.advice --input /approved/normalized --output /approved/advice
# Optional control-to-discovery links:
PYTHONPATH=src python -m sf_eval.advice --input /approved/normalized --output /approved/linked-advice --discovery /approved/discovery.json

The equivalent API is sf_eval.advice.evaluate(input_dir: Path, output: Path, discovery: Path | None = None) -> Path. Successful CLI execution prints the output directory/schema as JSON and returns zero. Invalid inputs, tampered hashes, unsafe paths, existing destinations, unsupported assessment codes and SQL errors return 2 with an error on stderr. SQL errors abort evaluation; no successful or healthy result is substituted. Inputs are read only; the connection enforces SQLite query-only mode. No warehouse or client writes occur. Human attestations are declarations, not authentication or proof of privilege completeness. Obtain client collection/privacy approval through the collection workflow before using real metadata.

The input is exactly the normalizer's sf-assessment-normalized-v1 directory. normalize.validate_normalized verifies its database checksum, schema, row counts, statuses and provenance before SQL execution. Every required source must be COMPLETE to support an observed classification; missing, denied, unsupported, partial and empty states suppress healthy/candidate conclusions. An empty result population produces an explicit insufficient-evidence observation. Nulls remain null. Required warehouse configuration/context fields, including AUTO_SUSPEND, must be known before any warehouse advice conclusion. A blank AUTO_SUSPEND is unknown; explicit numeric 0 means disabled. The protected SELECT retains its historical NULL interpretation in results.json, but advice overrides the corresponding classification to insufficient_evidence, retains actual_assessment_code/measurements, and supplies guard_reasons and explanatory observation text. It creates no candidate or proposed roadmap row from that unknown setting. Native query normalization supports only explicit SUCCESS and refuses the entire export on failed/unknown execution outcomes because the protected SQL does not classify failed work. The advice layer also defensively suppresses warehouse and SQL advice if non-SUCCESS execution-status metadata reaches it. The original SQL results remain separate from advice classification. Attributed normalized CSV or manual-context QUERY_WORK requires a structured query_population declaration of SUCCESS_COMPLETED, plus source attribution and attestation. The normalizer validates this declaration; free text claiming a status cannot substitute it. This attests a successfully completed query population, not independent native execution proof, and never requires an invented native query ID.

Inputs and outputs

Discovery JSON has exactly this shape; IDs are bounded literal references, not executable instructions:

{"schema_version":"sf-assessment-discovery-v1","items":[{"discovery_item_id":"DISC-001","control_id":"WAREHOUSE-01"}]}

Each discovery ID and control may occur once. Controls must be present in this tool's shipped rule catalog. Unknown controls, extra fields, duplicate JSON keys, duplicate references and null items are refused. No supplied mapping means null/empty discovery links, an explicit unfilled relationship rather than an invented interview. Discovery mapping supplies traceability only; it cannot authorize a finding, change a threshold or install a rule.

results.json (sf-assessment-evaluation-v1) retains account, role, half-open window, evidence kind, all 13 source states, actual query columns/rows/status/limitations, and an evidence index. observations.json (sf-assessment-observations-v1) contains observations, not an accepted findings register. remediation-catalog.json copies the qualified shipped allowlist. manifest.json (sf-assessment-advice-manifest-v1) hashes these final files, the normalized manifest/database, discovery input when supplied, catalog and code/SQL. No timestamps or output paths enter logical observation identity, so repeated runs of identical evidence yield identical output bytes.

Evidence records link source names, original source records/checksums/query IDs/attestations, normalized database checksum and capture manifest checksums. Manual source records retain their attribution and context checksum and have no invented native query ID. Missing sources retain UNKNOWN and explicit absence. SOURCE_COVERAGE is generated from the normalized database rather than represented as a native query. Each observation includes its resolvable evidence IDs, source query IDs, affected metadata reference, actual measurements, rule/version, assessment/control IDs, discovery links, untested hypothesis, prerequisites, alternatives, proposed owner, conditional/unassigned severity and measurable future acceptance. Metadata names and owner-provided free text remain untrusted data; this command emits JSON only. It does not emit HTML or CSV. A later exporter must escape its own output.

Synthetic evidence/observations use E-SYN-/O-SYN-; client metadata uses E-/O-, followed by 32 stable hex characters. Keep datasets isolated as described in register conventions. Account/role/window, source provenance and row measurements are included in identity; changing them changes IDs. IDs do not establish truth. No patient rows, query text or binds are required by these schemas.

Questions and control mapping

The 24 actual (query, ASSESSMENT) outcomes are allowlisted in the versioned catalog. Startup compares them with the protected SQL's actual ASSESSMENT branches; new/unsupported codes fail closed. The catalog references real controls and their existing authoritative source IDs; the baseline 74-control coverage catalog is unchanged. These are bounded additional observations, not full control coverage.

Assessment questionSELECTRelated control IDs
Does observed workload justify reviewing size, suspension or queuing against owner targets?W1_WAREHOUSEWAREHOUSE-01 size; WAREHOUSE-04 suspension; WAREHOUSE-02/03 queuing and mixed work
Do bounded inherited grants match approved required and forbidden access?W1_RBACRBAC-02 effective access; dependency preservation is a prerequisite, including the manual RBAC-05 review
Does approved sensitive-population policy configuration match requirements and downstream copies?W1_PRIVACYPRIVACY-02/03 masking and row filtering; PRIVACY-04 copies; persona effectiveness and population/context remain explicit limitations/manual checks
Do representative selective scans and join operators warrant review against approved purpose and grain?W1_SQLSQL-01 selective scan; SQL-03 grain; SQL-04 spill context

Seven candidate categories remain distinct: warehouse size, suspension, queuing, access alignment, privacy requirements, selective scans and join grain. Combined SQL outcomes may carry two categories. Required service/business paths are strengths with no removal proposal. Object grants lacking USAGE, approved exceptions/alternatives and spill context stay contextual. Policy presence is configured protection with effectiveness unproven. No-observed-candidate is a bounded strength, never a statement that the estate is healthy. Missing sources/context remain insufficient evidence even when an inner join produces no rows.

All owners are proposed roles. No severity, target, implementation date, business impact, monetary rate or savings is inferred. Advice asks owners to agree measurable targets and comparable volume/cache/concurrency/correctness conditions. It does not convert a signal into a mandatory resize, policy purchase or grant removal. Required service paths and legitimate full scans/many-to-many joins are retained. All future experiments/changes need separate authorization.

From observation to finding and roadmap

Lee and the appropriate client owner first challenge population, scope, source timestamps, attestations, omissions, approved requirements and business applicability. Resolve the evidence IDs to approved controlled exports and reconciliation notes. Record corroborating interviews as testimony, not runtime proof. If supported, create a separate F- finding in the existing findings register, linking the original evidence and recording owner validation, actual impact and unresolved causal hypotheses. Retain rejected/contextual/unknown observations with their rationale; do not silently promote them.

Only then propose an R- roadmap package with findings, dependencies, prerequisites, alternatives, required approvals, proposed owner/capacity and owner-agreed future acceptance. Reconcile both finding-to-roadmap and roadmap-to-finding links using existing register conventions. Unknowns become evidence requests/decision records with an owner. No finding or roadmap record is created automatically here. Manual fallback is the existing control interview/artifact method, recording population/window/limitations and native query IDs only when actually observed.

Verification and limits

PYTHONPATH=src python -m unittest discover -s tests -p test_advice.py -v

Tests cross the actual normalizer, read-only SQL and subprocess CLI boundaries; assert repeated hashes/IDs, healthy/remediation/unknown and client/synthetic separation, provenance/discovery resolution, required service preservation, configured-versus-effective protection, malformed discovery and unsupported-code/tamper refusal. A six-case full capture→assessment subprocess regression tests blank versus explicit zero versus known-positive suspension for small and large warehouses, preserving original SQL results while suppressing unknown-setting conclusions and proposed roadmap rows. Existing practice SQL tests supply broader rule metric falsification. Native Snowflake compatibility, privilege completeness and client assessment are not established by these offline checks. Independent release acceptance remains required.

Retained mapping and report-verifiable provenance

Current evaluations retain exact discovery JSON bytes as results.discovery_payload_base64 plus discovery_sha256, and preserve the normalized query_execution_status map. The evaluation manifest repeats the discovery byte checksum and includes rule_catalog_sha256 (shipped catalog bytes) and rule_catalog_canonical_sha256 (canonical semantic JSON). Without discovery input, checksum/payload are null and both primary and related observation discovery references remain empty. The report verifies mapping bytes/checksum and parsed exact control-to-discovery references, catalog semantic equality with the shipped catalog, and reconstruction of observation/evidence/query/measurement links from evaluated query results. Older evaluations without these fields must be regenerated, not patched by hand. These are internal consistency checks, never authentication of client evidence, privilege completeness or approval. Narrative display strings remain untrusted text; they do not establish a finding or actual accountable person.

Current strict provenance also retains exact normalized-manifest bytes as normalized_manifest_payload_base64, covered by the evaluation manifest's normalized_manifest_sha256, and the actual normalized QUERY_WORK identifier list as query_work_ids. This makes source count/cap/status/type/manual/native declarations and native execution-map identity/count independently checkable within the evaluated artifact. Reports validate those structures using normalization's shared pure validator, check every expected code/SQL digest against shipped bytes, and require native_execution exactly NOT_RUN. A manual success-population declaration does not supply a native execution map. Regenerate older evaluations lacking these fields; do not patch checksums by hand. No checksum or duplicate retained structure authenticates a coherently replaced whole artifact set.