# Data boundaries

Raw media logs and event-level records belong in your authorized lake or warehouse. The customer Gateway reads them under your grant. Its native reader, warehouse fallback, aggregate-output checks and approved Partner Clean Room releases have different boundaries.

| Capability | Runtime | Status |
|---|---|---|
| Inspect public query rules, keys and scopes | Sandbox | Live |
| Restrict reads and exports to the customer grant | Tenant Cloud | Preview |
| Apply the tenant identifier-output policy | Tenant Cloud | Preview |
| Inspect proof examples from public-test Access | Sandbox | Preview |

## Where data sits

| Data | Where it sits | What crosses to Precise |
|-|-|-|
| Raw logs, event-level delivery, full datasets | Your lake or warehouse | The customer controls raw storage and the placement and credentials of its reader |
| Snapshot exports for a run | A prefix in your own bucket, stage or external location | Exports target the named prefix. Scope the provider identity to that prefix and validate object resolution on the chosen read path |
| Aggregates and run records | Computed by the Gateway in your cloud | The aggregate, its `run_id` and its `result_digest` |
| Business context and versioned summaries | Precise's store, scoped to your tenant | Held by Precise |

```mermaid
flowchart LR
  subgraph cloud ["Your cloud"]
    logs["Raw logs"]
    view["Granted columns"]
    bucket["Your bucket"]
    gateway["Gateway"]
  end
  precise["Aggregates and run records"]
  logs -->|named columns| view
  view -->|one fixed statement| bucket
  bucket -->|pinned snapshot| gateway
  gateway -->|output rule| precise
```

## What you grant

The grant is yours to write and yours to revoke. It names one reader, the columns it may read, the compute it may use, and the one prefix it may write to. On each cloud the recorded connection answers `"rows_leave_your_cloud": false`.

| Cloud | The reader may read | The reader may write |
|-|-|-|
| AWS | Named columns, through Lake Formation `SELECT` | `s3:PutObject` and `s3:AbortMultipartUpload` on one prefix |
| Google Cloud | An authorized view and query-job rights in the job project | Ordinary export and managed Iceberg have different bucket rights and principals |
| Snowflake | A view over the named columns | One stage you own |
| Databricks | A view over the named columns | One external location you registered |

The warehouse renderer rejects ungranted projections, relations and tenant changes before producing SQL. The destination is derived from the grant and request, and every statement reads one fixed source version. A catalog's row or masking rule is additional authority. The native restricted read applies supported predicates and requires reader attestation. The warehouse fallback refuses any table that carries catalog read restrictions, so a restricted table is read under its rules or not at all. [Cloud connection examples, SQL and provider requests](../data-and-measurement/cloud-connections.md).

The connectors are tested against local stand-ins for each cloud's APIs. A live connection is set up with you during onboarding.

## The identifier output rule

Every column in a governed catalog carries a role, and every catalog carries an output policy.

| Setting | Values | Effect |
|-|-|-|
| `ColumnRole` | `Identifier`, `Dimension`, `Measure` | Direct identifier projections are rejected on the governed SQL route |
| `OutputPolicy.allow_row_export` | `true` or `false` | Requests aggregate-only release on that catalog |
| `OutputPolicy.min_group_n` | A whole number of 1 or more | Sets the minimum group size at supported aggregation nodes. A floor above 1 also requests aggregate-only output |

For a policy refusal, read `not_computable` and the diagnostic code. These checks cover the SQL plan the Gateway can inspect.

| Code | When |
|-|-|
| `identifier-column-projection-prohibited` | The output projects an identifier column. The message names the column |
| `row-export-prohibited` | The catalog requires aggregate output and the query returns rows |
| `column-output-policy-unproven` | The Gateway cannot prove that the query's plan satisfies the policy |

`count` and `approx_distinct` over an identifier return a number and are allowed. This rule runs in the Gateway of a cloud deployment. The public sandbox serves a synthetic catalog with no identifier-role columns, so it has nothing for the rule to refuse.

The governed SQL analyzer fails closed across every expression variant, including quantified comparisons, nested sorting and `VALUES` expressions, and blocks direct projection or encoding of identifier sketches while allowing aggregate estimates such as `theta_estimate` and `hll_estimate`. An aggregate count and a serialized sketch still have different disclosure properties, and native snapshot reopening and warehouse exports carry different evidence. Keep sensitive identifiers out of exposed diagnostics and unvalidated joins, pin storage access to a provider-enforced prefix, retain source revisions and object digests, and require an independent release review and passing regression tests for each customer deployment before relying on it for restricted data.

One Partner Clean Room question releases identifier tokens by design, and both owners approve it first: building an audience. The destination receives tokens that tell it which of its own identifiers matched. [Partner Clean Room](partner-clean-room.md) states what that question releases.

## What the public sandbox enforces

The public catalog contains synthetic data. A read-only query for a nonexistent measure returns HTTP 422 `query_failed`.

```sh try expect=422
curl -s -X POST https://sandbox.precise.ai/api/sql/run \
  -H 'content-type: application/json' \
  -d '{"sql":"SELECT unlisted_measure FROM orders"}'
```

Recognized personal-field names return HTTP 400 `pii_not_accepted`. Statements outside the read-only SELECT contract return `query_failed`. These are recorded refusal codes. The sample above reads the published synthetic catalog.

Across the sandbox use synthetic aggregates. Its field-name filter is a fixture-level input rule. It cannot establish a customer installation's release policy.

## Tenant isolation in the control plane

The customer Gateway's cloud grant and the Precise Access database secure different resources. Access migration `004_rls.sql` enables and forces PostgreSQL row-level security on 24 tenant-scoped tables. The ordinary application role is a nonowner without BYPASSRLS. Its transaction-local `app.tenant_id` must match each row for both visibility and writes. A missing or empty setting authorizes no tenant rows. Protocol seller authentication uses a separately granted security-definer lookup for the exact live credential digest. Privileged DB administration and cloud warehouse authorization require separate controls. The PGlite and PostgreSQL 17 integration suites exercised tenant isolation under ordinary roles. The public sample workspace alone cannot demonstrate another customer's deployed database policy.

## Keys and scopes

| Scope | What it allows | Who holds it |
|-|-|-|
| `precise:read` | Read the book, the guide, the track record and verified runs | Scoped per-company key (`penv_...`) |
| `precise:query` | Run read-only SQL or a structured join on the pinned catalog | Scoped per-company key (`penv_...`) |
| `precise:run` | Run Gateway analyses, workflows and holdout sizing | Scoped per-company key (`penv_...`) |
| `precise:record` | Record and score Decisions in a workspace | Scoped per-company key (`penv_...`) |

```sh try
curl -s https://sandbox.precise.ai/.well-known/oauth-protected-resource
```

A per-company workspace key travels as `Authorization: Bearer <key>`. Any gated sandbox, SQL, Gateway, or MCP request without a valid key answers `401` with a `WWW-Authenticate` header that points to the metadata above, and the MCP error carries the code `workspace_required`. Request a private 30-day workspace key at `https://sandbox.precise.ai`.

## Where to go next

- [Partner Clean Room](partner-clean-room.md): the boundary between two data owners.
- [Offline verification](offline-verification.md): check a result on your own machine.
- [Limits and errors](../../reference/limits-and-errors.md): the limits, the headers and the error codes.
